One of the aspects that seems to be missing from this topic is the maturity of the players and how they deal with morality. I often have very young players. Moral challenges and moral ambiguity are difficult concepts and I avoid presenting those elements in the game at their early age.
The heroes fight monsters. The monsters are not human. Monsters are evil. The monsters are unwavering in their commitment to destroy, execute their plans, and be evil. The heroes defeat evil.
Later, evil humans in the form of bandits, despots, necromancers, etc. come into the game. These humans are clearly evil and are unredeemable.
Eventually, I do introduce moral challenges: such as the defenseless monster, the pitiful monster, the surrendering monster, and the negotiating monster. How they act in those situations has an effect on their world and how the world treats the characters.
The land still has a law. And breaking the law will have consequences. Unwarranted casual slaying of anything will result in negative consequences: arrest, revenge, denial of services/favors/aid, etc. Reputations are ruined in these situations and the "murder" will need to be atoned for before the reputation as a hero is restored.
Snarky comments from kings and lords, archmages and high clerics, and bards and patrons, are stinging rebuke for character misconduct, even if they acted in a grey area. (sure, goblins are evil, but the one they killed was defenseless and chained to a pillar; so now the party is viewed as merciless and bloodthirsty, which is not a good reputation for a good party or one with a paladin.)
Rogues, which operate one the edges of the law in the first place, are most susceptible to immoral play. As heroes, their past transgressions are somewhat forgiven and any practice of their larcenous arts for the greater good is winked at. However, being associated with immoral acts, murder, etc. now causes them to run the risk of arrest anytime they venture near law enforcement as they are already known criminals and this immoral act only proves that they are worse than thought and must be locked up.
The world, even the fantasy world, is the best corrective measure to immoral character activity.
In the end, they could never become so powerful they are held unaccountable for their activities. In this fantasy setting, there is always a more powerful warrior, more powerful wizard, dragon, giant, demi-god or god that can exact retribution.