Back in 3rd Edition D&D there was a spell called "Holy Word" that could kill non-good creatures within a 40 foot radius of the caster, if the caster was sufficiently high level relative to the creatures. Good creatures were completely unaffected.
When tightly packed you can fit about 2000 people into a 40-foot-radius circle (total area is 5000 square feet). So one casting can deal with the population of a good-sized town. My gaming group speculated for a while about a society where it was a routine ritual to round up all the peasantry and nuke them with Holy Word to keep the population clear of evil. Never incorporated it into any campaigns, though. It's a bit of a sticky philosophical puzzler.
This is a weird one because despite being a "good" spell, it entails the mass murder of innocent neutrals. It really doesn't seem like a good action to me.
It seems like anyone who was okay with this would fall to neutral or evil simply by virtue of being okay with mass murder, and in turn fall victim to the Great Neutral Purge.
Indeed, hence the sticky philosophical puzzler. I would think that the clerics themselves would start getting affected by the spell. Fortunately (for them), the effect of the spell when cast on someone of the same level as yourself is only deafness for 1d4 rounds. The Church could probably cover that up.
There was another interesting related situation that came up in an actual campaign I was in, involving the Blasphemy spell (a variant that only kills non-evil targets). My party and I were in our "home base", a mansion belonging to an allied NPC noblewoman, planning out our next excursion. A powerful demon we'd been tangling with attempted to scry-and-fry us, teleporting in and nuking us with Blasphemy. Unfortunately there were a lot of low-level NPC staff working in the noblewoman's household and the spell wiped them out instantly... except for one guy, who happened to be of evil alignment. He survived the encounter because of that.
Even though his alignment was evil, though, he'd never done anything wrong and didn't seem like he had any reason to do anything wrong in the future. So we weren't sure if we should fire him or what. It wasn't illegal to simply be evil, you had to actually do something evil before you could be punished. We just warned him we'd be keeping an eye on him, in the end, and kept him on staff.
Okay, he hadn't done anything wrong to us. I guess we could have paused the main campaign to spend a while investigating him, but we were doing one of those save-the-world things so we didn't have the time. :)
I feel like there might be interesting ways to deal with it. Perhaps the mass killing of neutrals only ever happened the first time, which could have been many generations ago and under singular circumstances. Since then, only the odd one here or there ever dies during the purge. Perhaps it's been decades or centuries since anyone died to the purge, reinforcing belief in it's effectiveness as a basis for a pure society. It may have been so long that people wonder whether the purge is even real, or just a traditional ceremony carried out annually based on old myths. Then one year, it wipes out half the city. The party investigates?
What is being good except having self-imposed restrictions to avoid doing something evil? This spell seems perfect. There will rarely be a time where a good aligned character could justify using it in an overpowered way. If it were inverted then you would see evil characters using it all the time. It's a self-imposed balance. You have a very powerful tool, but you must avoid using unless absolutely necessary.
Ah, but there is an evil equivalent, Blasphemy. It affects non-evil creatures instead of non-good creatures, and as such has no self-balancing properties. There are even equivalents for Law and Chaos, which are... worryingly abstract.
Here’s the SRD entry for the spell. It definitely nukes the neutrals.
Which is kind of horrifying because most of the population of any given setting is supposed to be neutral. The average commoner isn't so greatly committed to following airtight moral codes that they'll ping on a detect whatever spell, whether that's good, evil, law, or chaos. Cast that on a crowd of randoms and you've probably wiped out three quarters of them.
It was a bit different back in the 3rd edition days, "good" and "evil" were slung around a bit more liberally. I believe it wasn't until the 5th edition when they introduced the "unaligned" state, which is sort of "neutral but without the commitment", and assumed most average folk were unaligned.
Presumably before the high cleric casts Holy Word there'd be a festival ahead of time in which people are given plenty of opportunity to donate to good causes (ie, the Church) to crank up their good meters before being "tested."
Another aspect of the puzzle is that not every evil deserves death. A bum who does minor theft almost as a habit, a hateful bitter man who antagonizes everyone but obeys the law, a teenager, a greedy business person who employs half the town but makes everyone's life a bit worse, and so on.
Good should have the self restraint to not go straight to murder.
Situations like this give me the inclination to treat D&D Good™ and Evil™ as physical properties rather than moral tendencies. D&D Good™ that is a little too eager to murder beings labeled as Evil™ falls short of what I would consider good. If someone used such power to kill someone who is a pathological liar and petty thief, that wouldn't seem good to me even if that person could be classified as Evil™ as the system defines it.
Then again while to me such act seems evil, I don't think I could call the caster Evil™ because D&D explicitly endorses killing Evil™ creatures as a Good™ act. Since the 1st edition, the purest paragon of Good™ that is the Paladin wields a weapon to kill.
5th edition has done it better with the addition of "unaligned" to the mix, IMO. In order to have an alignment - even a neutral one - you need to explicitly dedicate yourself to that alignment, or be supernaturally bound to it such as with angels and demons. I would rule that these spells don't affect the unaligned.
It is definitely more convenient for players, especially now that they dropped class alignment requirements, but there is so much worldbuilding tied to Good and Evil and such, it feels a little strange to treat it like something most characters ignore.