I've built a lot of villages, some towns and a city or two but I've failed to bring them to life and make the PCs feel like they belong there (maybe not much belong but to just make them care about the place); a troll could probably eat the entire community and the PCs wouldn't really care.

Does anyone have any methods for making players care about the Community they live in and grow to care about the people living there?

Give them unique resources/opportunities

Services and opportunities help disguise the ploy a little better; perhaps the town is unusually good at generating cool quests or provides unusually good legal counsel (if that's the kind of game you're running). You don't need to discount the services if they're superlative or difficult/impossible to come by elsewhere.

Have them help you design it

Ask for their input designing the town, from letting them name the NPCs and taverns to even toss them the whole job while you make some tea. (If you leave it up to them, be sure they have town-generation guidelines from the game book or somewhere else; they probably aren't as experienced at this as you are.)

This makes the players are personally invested in the locale, and ensures that it's interesting to them.

Make them its guardians

Have the party save it as part of a different quest, and have the townsfolk acknowledge this effusively. Play it up to the PCs' egos: coming to the town means children following them, free drinks, and maybe checking the progress of the statue in their honor.

Make it memorable with people, not stuff

Elaborate setpieces are cool, but to engage the players with a town you need interesting people in it rather than fancy geography.

Maybe the mayor is an inventor who spends his limited free time (the duties of mayorhood are endless) creating quirky labor-saving devices. Or the whole town is freakishly obsessed with a particular kind of animal, breeding them and hosting regular pet show style contests.

Don't oversaturate

Players shouldn't be expected to develop intimate connections to every hamlet they run across. Pick one or two locations that you'll be coming back to regularly --preferably they're related to the story at hand, to make it feel more natural-- and focus on them.

+1 for making people rather than stuff. When our carefully-rebuilt-from-the-ashes city was threatened by troglodytes, we were honestly upset because Lia and Valen and the birdcage kid might die!
–
thatgirldmApr 10 '13 at 4:21

Everyone comes from somewhere. PCs in our group are required to have a hometown and a family background. But requiring it is only the first step. To make it matter, I give the PCs boons and hindrances because of their background. For example, one of the PCs is a local landowner; she can call on the farmers of the area for help, but she's also expected to offer hospitality to anyone who visits her land. If a PC is from a community, they're more likely to care about it.

Towns recur. Keep bringing the story back to the same town. This way, each time the party returns, all the history they have there returns with them. In the first adventure of our campaign, the party dealt with a city abandoned due to plague. They explored the city like it was a dungeon, exploring building by building. The next time they were in the area, the ruler of the city sent them an invitation to come and visit. Later on they followed up on the invitation, and the ruler gave them gifts in recognition of their service. Because the story keeps coming back to the same city, the party has a very strong sense of that place.

Have an NPC identified with that community. People are good at identifying with people. If you want the party to get to know a community, put an NPC in the story that is strongly linked to that community. This works with a town, but it works just as well with introducing a different tribe, ethnic group, or species.

The people of that place keep doing things in the background. If the people who live there are always doing things, they can keep coming up in the story. In the example above, the city gets mentioned a lot because the people of that city travel around and do things. When the party hears about a place they've been to, it helps keep that place present in their minds.

Every town has a quirk. Give a place something to distinguish it, even if it isn't much. Make that one thing stand out. For example, don't have a farming village, have a village that grows carrots. Don't have a town with plain stone walls, have the walls painted a brilliant white. Don't have an ordinary hamlet in the woods, have a hamlet at the base of a waterfall in the woods.

Make unimportant places unimportant. If every important settlement has an interesting name, a quirk, important people, etc.; make sure that unimportant places have bland names, no special quirks, and no memorable people.

Adventurers don't care about communities because they are not part of them. They don't know these people, they don't have anything to do with these people, there's no reason for them to care. They don't interact that way. It's one of many unstated assumptions of D&D and similar games: towns are background. Adventurers go there to replenish supplies and get new quests, before going and doing something they actually want to do. This is why providing them with benefits, as BESW suggests, is worthwhile but hard: the game is not made with such benefits in mind.

There's plenty of excellent advice in other answers here on how to make communities interesting, but none of that is going to matter unless players actually interact with them. So have them interact! Have them become members of the community, have them earn their place there. Bring the community from the background to the foreground.

How? By having adventures inside the community, with more personal plots. A murder mystery. A werewolf plot. A rebellion. A feud. All of these (and plenty more) offer ample opportunities for PCs to get to know the people that make up the community, to get tangled up in their personal dramas, to affect them and, ultimately, to become invested in them.

Once the players are invested, have the consequences of their successes, failures and choices reflect upon the community, even when they're adventuring away from it. The wizard they've rescued settles nearby, unsettling villagers. The merchant they've refused to guard doesn't make it, and starvation sets in.

I like most of the answer, but I disagree that its an unstated assumption that towns are background. Sure some adventures are run that way, but it is not so in many other adventures and certainly not that way in the novels or setting books. Silverymoon and Menzoberranzen are iconic in the Forgotten Realms for instance. Towns are background only if the GM treats them that way.
–
TimothyAWisemanApr 10 '13 at 16:52

It is certainly a point of contention. I think that while D&D and its surrounding fiction certainly can involve towns and communities, the rules encourage the opposite. There is nothing adventurers need from a town, other than somewhere to offload their loot.
–
MagicianApr 10 '13 at 23:43

Everyone doesn't prefer the same types of communities. People like places that provide them opportunities, support the lifestyle they prefer, and surround them with the right kinds of experiences. They'll want to work on behalf of the community if they feel its well being is tied to their own.

The city that houses the Wizard's Collegium is unlike any other city
in the kingdom; you can't hope to get access to the most powerful
magical items and higher-level spells unless you come to this city and make the right kind of connections with the right kind of magicians.
If the city is threatened, so is the party's access to that magic.

Because it's situated at the head of Razor Pass, the small hamlet
provides ample opportunities for adventurers who hire on as seasoned
guards for the traders who move through the area in the spring and
summer months. The adventurers only get the work if they're able to stay on the good side of the local merchants and tavern keepers, who make recommendations to visiting traders. This sort of work would be much more difficult to find
in any other part of this district. Now imagine a plague sweeping
through the town, thereby threatening the flow of lucrative guard
contracts.

Sure, you can get resurrected elsewhere, but the main temple to the
Sun God is here in this small, otherwise nondescript town. They will
resurrect adventurers, but they always take payment in favors, never
in cash. After a couple of these favors, the adventurers will have a
much tighter connection to the individuals at the temple who literally saved their lives, and by extension the town.

It can also be handy to make a community the place where geographic, cultural, and political boundaries intersect.

The characters have been fighting the Northern Orks on and off for over a year. They need more info about them so they can pinpoint their lair and wipe them out for good. Fort Solitude is the place to go, because there are a fair number of half orcs who live there, and the fort is its own political entity, neutral in the disputes between the Empire and the Ork Confederation. Some less than savory individuals provide the most useful information, and keeping them alive is vital. While the characters are in the service of the Empire, they know it is to their advantage that the fort maintain its independence.

Every summer the seven tribes meet at the Diamond Oasis for the Tribal Gathering to trade, conduct negotiations, make alliances, and arrange inter-tribal marriages. During the rest of the year the oasis is barely inhabited, but clever adventurers could turn a week's worth of Tribal Gathering into a year's worth of paid work. They could hire out as mercenaries, go on short quests for shorthanded chieftains, and engage in subterfuge for the party with the most coin. They have to tread carefully, lest they make enemies while serving those with the coin, so they'll have to maintain contacts with all the tribes. If the Western Hordes come riding through on their war beasts, threatening to destroy the Diamond Oasis, the adventurers' livelihood is being threatened.

Make the community respond to the players. Players like to see their effect on the world. If they put out a burning orphanage, have one of the orphans take kindly to the party and show them around town whenever they show up. If they shut down an evil cult and destroy its base of operations, but a tavern there that always gives the PCs free drinks. It doesn't matter what these effects are - they should just be things that the players know they put on the map. Make them feel like they own this town.

I'm not sure if you would consider this an answer, but what my old DM used to do with me and my friends when we played was to twist our arms in a sense.

He would have of us do a few things around the towns or cities, and in doing so made us do some serious hard labor. Once we put our blood and sweat into the town or city (so to speak), we felt like we deserved to have a place in the area. A friend of mine was the only pally in our group, and he felt so determined to keep certain areas "special". But there were always special towns or cities that we paid special attention to, just because we worked so hard for those people. Even the thought of them dying or being destroyed brought out a not so nice side of us, even from the pally!