1) Commoners are Shameless: Townsfolk will happily cooperate with murderhobos as long as they think that they can avoid horrible deaths or equivalent suffering. They won't like it, but they've no shame at doing what it takes to survive. This often lulls murderhobos into a false sense of security.
2) Commoners are Ruthless: If pressed to the limit, Townfolk will ruthlessly defend themselves from murderhobos. They will not play fair. They will get murderhobos drunk. They will subtly poison their food. They will carefully launch assaults on sleeping murderhobos. If they capture murder hobos they will not simply throw them in a locked room. They'll gouge out eyes, snip off tongues, break fingers, and place prisoners in canques and stocks. They'll not relent and they'll not take chances. Misuse of magic by the murderhoboes will be seen as full justification for treating murderhobos as monsters.
3) Commoners have common Protectors: Remember that every village has to at least defend itself against bandits (human or otherwise), occasional low level undead, the occasional lycanthrope, and the depredations of the occasional wandering monster. Every human village is equipped in various small ways to face off against monsters. They'll have priests and other spiritual leaders who are low level spellcasters. Larger villages will have hedgewizards and the like providing low level arcane ability. They will have a small force of town watchmen who are skill low level rogues, rangers, fighters or the like. They'll be skilled in using nets, mancatchers and similar restraining devices and be skillful in perception. They'll have loyal and potentially vicious watch dogs that assist them in their work. They'll have access to emergency stocks of silver crossbow bolts, flaming oil, and other means of attacking creatures normally resistant to attack. Border villages and towns will have an outpost of the Guard in a fortified motte and bailey keep. The guard will be well equipped and trained. They'll have messengers and horses on standby to summon reinforcements from neighboring villages. Each village is also typically protected by a landed knight who is a mounted low level fighter and who has various competent retainers and family members, and who is expected to sally forth from his manor and deal with vagrants and bandits.
Individual homes are of heavy timber construction and in wealthier areas stone. They do not generally have locks which are expensive and considered untrustworthy. Rather homeowners bolt and bar doors from the inside and shutter and bolt windows. Living spaces are generally on the second floor, with workspaces and livestock on the lower floor. Every space however is someone's bedchamber, as peasants are generally too poor to waste space. Maids, scullions, servants and so forth are sleeping everywhere and a hue and cry will easily reach and wake the entire home (and soon the neighbors). No home is considered complete without a guard dog or similar trained animal. Older wealthier homes attract denizens such as brownies who 'adopt' the inhabitants as 'pets' and will act to protect them. Older homes that have been continuously inhabited attract household spirits or naturally become semi-sentient spirits in their own right, and will act to subtly protect their inhabitants with various minor magical blessings and protections.
Every household has simple weapons like axes, clubs, bows, mattocks, and knives. Most families have a spear or polearm tucked away somewhere. In the event of a disturbance, the village militia will turn out, consisting of at least the village men capable of bearing arms. This generally results in a small army of 2nd-4th level commoners and experts turning out to defend their neighbors - whom are often cousins afterall.
Really vicious evil behavior is likely to attract at least minor attention from protective deities. No deity likes having their temples and altars desecrated or their priests massacred within their own sacred spaces. Nor are they particularly happy to worshipers slaughtered. They will likely intervene in minor ways, sending minor servants to protect the townsfolk and help them escape the PC's clutches or intervening subtly by granting various protective magic to the most pious. Remember, these villages are typically pious for a reason. Even if there is normally only a 1 in 100 chance of getting a deities attention, the odds approach 100% that some innocent individuals plea for aid will be heard. Also keep in mind that in a sense, each village or town is a dungeon, and the sort of things you'd put in a dungeon to thwart PC's appear in corresponding force in the town (otherwise, the dungeon inhabitants would be much more aggressive in taking over the town).
4) Things escalate quickly. If the murderhobos start killing family members, they'll soon have the whole village to deal with. If the murderhobos massacre a village, they attract national attention. They'll be declared bandits. Bounties will be offered. A description of the PC's will be circulated amongst all village watches. Folks in taverns everywhere will talk about the incident. The PC's won't necessarily be immediately made wherever they go (but if they are a mixed race group they probably will be), but they'll provoke curiosity and suspicion. The suzerain will detail knights, hunters, and mages to track down the PC's. Various churches associated with justice will detail parties of clerics, champions, fanatics, and inquisitors to hunt down the PC's. These will typically be mid-level characters. They'll have access to divination magic and will use it appropriately to learn identities of the PC's. They'll behave with all the cunning that the PC's themselves would exhibit tasked with the same job. Young knights will take it on themselves to go on a quest to avenge the villagers, hoping thereby to increase their fame and improve their resume. In short, people take legitimate threats seriously.
If things escalate again, the PC's will attract international attention. Word of their infamy will reach legendary heroic figures. Churches involved in justice or the hunting down of monsters will send out their highest level paladins and most skilled inquisitors to track the PC's down. Unless the PC's are already some of the highest level characters in the world, this is likely to end badly. Companies of mercenaries will take it on themselves to hunt the PC's down in hopes of winning acclaim, rewards, and titles for themselves. In short, the PC's will find NPC equivalents hunting them as the objects of their quest. They will become some other group's boss fight. The PC's will not be safe anywhere in civilized lands.
None of this requires metagaming by the DM, nor do you need to break the rules of the game. Indeed, enforcing a bit of realism usually works to your advantage. Rather, all of this can be justified by a very simple principle - there is nothing the PC's can attempt that is unlikely to not have been tried before. A few PC's cannot easily take down a society that has endured for centuries or millennia. They are certainly not the first group of persons to have come along and imagine they can get away with abusing people. If they want to become the villains in the story, then they face off against the full might of the most successful and powerful communities in the game world. If wiping out villages of goblins or orcs involves hazards, how much more hazard is involved in facing off against the communities that have conquered the most territory in the game world?
To be honest, though I've seen it and even down things of a similar sort as a player, I've never really had a problem with this as a DM. Most players do not play heroes, but they generally do not play murderhobos unless encouraged to play that way by the DM. Usually PC's fall somewhere in the spectrum between noble heroes and vile villains. If you see PC's playing as murderhobos, chances are you're at fault as the DM. The way you end up with murderhobos is typically you make every NPC both incompetent and unhelpful. NPC's that are unnecessarily rude and act against their own interests to frustrate PCs will end up frustrating players. If all NPC's betray and misuse PC's without reason, PC's soon learn that the only way to profitably interact with NPCs is to dominate and kill them. Murderhoboism is an evolved behavior for dealing DMs always being out to get them. These DMs typically treat NPCs entirely like they are there to be obstacles. If PC noble behavior is met with noble and generous responses, and if NPCs are actually competent and helpful, most PCs will take a more nuanced approach. But if every NPC acts like an enemy anyway, then there is no opportunity cost in treating them like enemies.
Another common problem I see is making the good NPCs have all the good stuff, but not the competence to protect it. This leads to a situation where looting the town is safer and more profitable than looting the dungeon. Again, you can and should reasonably assume that the PC's are not the first people to ever try tricking or abusing a society. Do not assume stupidity on the part of the 'good guys'.
In a society where magic is known to exist, when doors open seemingly at random, the first instinct of people won't be 'the wind did it'. The first thing they'll assume is that there is some invisible creature about (even if it really is just the wind). People will be superstitious and fearful because they have good cause. In a world where illusions can make copper coins look like gold coins, merchants will forearm themselves against such trickery. For example, the most common magic item in my campaign is scales which detect magic and give off some sort of warning whenever a magical item is placed on the scales. Such magic (detect magic) is very low level and accessible to almost any society with even basic magical knowledge, and attempts at magical trickery will be taken seriously because they are serious. For example, attempting to use Charm Person on someone except in self-defense carries the death penalty in my campaign. If you are caught, you'll be treated as a monster. And again, the PC's will not be the first persons to learn magic in most cases.
No character attempting murderhoboism has ever survived long enough to become a problem. Generally players prone to this will try to get pushy long before their character really is so high of level that they can't be dealt with. And if they attained high level by at least partially heroic actions, they'll get treated as heroes and this feeds the ego of a player prone to murderhoboism so that they prefer to retain the esteem of the NPCs and so gain the glory, attention, respect, and rewards that they crave.