Here is a truly profound quote by Bertrand Russell:
"The conception of Sin which is bound up with Christian ethics is one that does an extraordinary amount of harm, since it affords people an outlet for their sadism which they believe to be legitimate, and even noble."
People have natural cruelty in them, and they also have a natural desire to view themselves as good. The concept of sin allows them to satisfy both; they get to indulge their cruelty by punishing the sinner or by cheering the punishment from the sidelines and at the same time they get to retain their belief in their own goodness because the concept of sin has built into it the idea that the sinner had it coming or even that the punishment was for the sinner’s own good. That doesn’t mean that there is no genuinely evil behavior deserving of condemnation and punishment, but the existence of this really nasty bias ought to make one set the bar for doing so pretty darn high. Here’s another by David Brin:
"While there are many drawbacks, self-righteousness can also be heady, seductive, and even… well… addictive. Any truly honest person will admit that the state feels good. The pleasure of knowing, with subjective certainty, that you are right and your opponents are deeply, despicably wrong.."
Allowing yourself to enjoy your own rightness and the other guy’s wrongness might have some merit if it is something that you give yourself as a reward for fighting genuine injustice. But the fact that it is so much fun (Brin believes that it is literally addictive in the brain chemistry sense) ought to make you very suspicious of it; if it’s that much fun you are going to want to adopt the beliefs that allow you to get it in its purest and tastiest form, and such beliefs are unlikely to correspond to truth.
Jonathan Haidt writes about the Myth of Pure Evil in The Happiness Hypothesis. There is much to learn on human bias from this book.
Agreement with the basic observation: self-righteousness is addictive. So addictive that whether or not it arises in a religiously-observant context, it takes on a religious flavor, as in numinousness/ritual and a kind of unholy priority. An activist I knew in law school when challenged for his self-righteousness bristled quite sincerely with the all-purpose response: "But I'm right!"
Years ago there was a neurology article in the NYTimes reporting that social dominance (agency + superiority, in my definition) itself was associated with powerful endorphins.
Cruelty is at root, I believe, associated with the question of agency (and survival), "do I exist and have an impact on the world?" probably stemming from perhaps-inevitable deficiencies and excesses in child nurturance.
The work of Rene Girard -- mimetic socialization > envy > cruelty for social cohesion -- probably applies here too.
I am active in a Christian religion, and anyone paying attention recognizes the superhuman tension arising between the arenas of--discriminating between the "Two Ways," and--the obligation to see oneself as "chief sinner" for the purposes of the undertaking.
In view of the anxiety roused by real moral self-examination, there is an inevitable temptation to resort to comparative self-righteousness -- an odd kind of relief in personally "immanentizing the eschaton," unilaterally declaring the desired conclusion without actually meeting the standards. Religious practice addresses this in part by recommending, unless an institutional responsibility requires otherwise, focusing only on ones' own sins.
Even as to those who rationally dismiss religion, any kind of hard-wired conscience qua Natural Law or acquired socialization morality may create a phenomenon that when ones' behavior fails to meet its requirements, the "wrongness" can easily and covertly get projected onto the world at large, IMO.
In short, yes to the description of the phenomenon, yes to the frequent arising in religious contexts, no as to any necessary connection with religious practice and aspiration. It's almost everywhere in small and large degree.
For the purposes of discourse, the ubiquity of the self-righteous bias probably means that the phenomenon should be bracketed, not disqualifying what is said, and facts and logic on all sides be addressed without the red-herring of whether there is self-righteousness displayed or inferred. Otherwise it's one of those receding mirrors, a siren-song of reciprocal self-defining accusations.