That 2nd level cleric can cast 2 spells a day! Is he really holding back from helping the needy just because they can't afford his fee. What god of healing is going to stand for a priest that won't heal an injured child just cause the parents are poor farmers? I know this doesn't change a big part of your point, but we shouldn't assume DMG based definitions of fees would apply to all... maybe priests charge like some pharma companies do - you in England can afford to pay so cough up, you in sub-Saharan Africa can't, I you can have it for a lot less.
Well, yeah, he is holding back...in the same way that just because the local commoner COULD give his 1 sp/day to charity, he instead keeps it for himself; or how the local expert COULD make more horseshoes, but he's feeling really tired from the wife and kids.

Basically, casting spells costs effort, and if he doesn't see a need, he won't make the effort.
Aside from that 'natural human instinct to take things easy', there's a few details. He might not serve a god of healing, for one.

But assuming he does, he's gotta have a reason to use those spells...to him, the stubbed toe or the scraped knee just doesn't require his attention...he doesn't want every wounded victim coming to him, and he doesn't want the people to forget how to make bandages and Heal checks. So he charges. Sure, if he's a Good Guy, he's around for emergencies and the like...and that's why he doesn't heal everyone who wants it.
But most importantly, think of the monsters. Those who fend them off need that healing, more so than Farmer John and his Scythe Accident...there's no way that he could, even with that magic, ever heal every wound caused...natural healing will have to do. And assuming the 2/day encounter rate, he's going to need to spend his spells (including most of the scrolls he's scribed) healing the most wounded victims of that.
He'll save lives...but those lives would definately be lost without magic. Natural healing only would mean that it's a war of attrition between the hp of the town and the damage the monsters can deal. The cleric's
cure light wounds (possibly free of charge as a 'perk' of being a member of the militia) ensures that those who defend the town can continue to do so.
The price exists for those who want the convenience of doing it when the cleric isn't that interested...he'll help out his friends, he'll 'do his duty,' but he's not going to give broken bone a
cure. The populous would get lazy, those who suffer in defense of the town wouldn't be hurt, and he needs some way to pay for those scrolls he's scribing for the emergency situations. In addition, it's 'work.' Rest assured that on his day off, he's not casting anything.
2- on the raiding issue - the random encounters at 10% is just that - a random encounter. That could be with a friendly farmer taking his produce to town, or with deer grazing in a forest... no farmer is going to continue to live somewhere where gnolls attack as often as you say - he won't be able to produce food, which means the local knight/warlord/whoever is going to send in something to deal with those gnolls - otherwise there isn't any food for the warlord to buy, so his troops are going hungry as well.
True, not all encounters need to be hostile, but all encounters involve a 'challenge' of some sort. One of the random plains encounters is a 5th level paladin...he's not going to attack the town, but he is going to create a disturbance, and maybe his presence attracts something that *does* attack the town. A deer in a forest isn't an encounter (there's no EL, there's no XP for 'overcoming' it, etc.), so thousands of those happen regularly without a problem. That 2/day figure basically shows the 'challenges' the people of the town overcome.
In addition, the farmer farms that dangerous region largely because he has no choice. It's the best life he can lead. Either farm with the gnolls or sell trinkets in city squallor, and one of them his family's been doing for generations.

The gnolls weren't as bad in his pappy's day, etc. And the reason he can still survive is *because* there are more powerful beings than him in the world who can protect him, who can ensure food to eat, etc. D&D towns probably have great storage systems, because the chance that monsters will destroy everything you own is almost more of a 'when' than an 'if.' In addition, a
purify food and drink makes the storage not requiring complex cooling mechanisms or the like. "Gruel" is basically
purified stuff that rotted away last year into a paste.
And aside from that, the king *definately* sends troops to help out...where do you think that cleric came from, or that fighter? Certainly not the town, they don't have enough to outfit such people...they've been sent from outside, from the castle, from the city, and they live in the town on a temporary basis. They probably teach the kids for a year or two, and leave at the end of their term back to the castle, being replaced with new people,too, and taking the 'promising youths' (those who've gained a lot of levels) into the larger cities.
I imagine the Machiavellis of D&D definately have something to say about 'buffer farms.' You have commoners farming the lands around the central druids or clerics field; the commoners' farms can be lost in monster attacks, and as long as the main field stays operational, the town can still eat (because the yeild would have been increased by minor magic).