One thing the Bible makes clear is that self-righteousness is the premier enemy of the Gospel and no group of people better embodies the sin of self-righteousness in the Bible than the Pharisees. In fact, Jesus reserved his harshest criticisms for them, calling them whitewashed tombs and hypocrites.
In his book The Prodigal God, Tim Keller rightly shows that the Pharisees were the primary audience Jesus had in mind when telling the parable of the prodigal son in Luke 15. The Pharisees are compared to the elder brother, the one in the parable who "kept all the rules", and did everything he was supposed to do. The elder brother is not a long-haired, tattooed indie rocker; he's a clean-cut prep. He's not a liberal; he's a conservative. He's not irreligious; he's religious. If you've ever read S.E. Hinton's novel The Outsiders, than you'll immediately see that the younger brother in the parable is like a greaser, while the elder brother is like a soashe.
Now, it's very interesting that in the Bible it's always the immoral person that gets the Gospel before the moral person. It's the prostitute who understands grace; it's the Pharisee who doesn't. It's the unrighteous younger brother who gets it before the self-righteous older brother. Tim's book points this out well.
There is, however, another (perhaps more subtle) side to self-righteousness that younger brother types need to be careful of. There's an equally dangerous form of self-righteousness that plagues the unconventional, the liberal, and the non-religious types. We anti-legalists can become just as guilty of legalism in the opposite direction. What do I mean?
It's simple: we can become self-righteous against those who are self-righteous. Many younger evangelicals today are reacting to their parents' conservative, buttoned-down, rule-keeping flavor of "older brother religion" with a type of liberal, untucked, rule-breaking flavor of "younger brother irreligion" which screams, "That's right, I know I don't have it all together and you think you do; I know I'm not good and you think you are. That makes me better than you." See the irony?
In other words, they're proud that they're not self-righteous!
Listen: self-righteousness is no respecter of persons. It reaches to the religious and the irreligious; the "buttoned down" and the "untucked." The entire Bible reveals how shortsighted all of us are when it comes to our own sin. For example, it was easy for Jonah to see the idolatry of the sailors. It was easy for him to see the perverse ways of the Ninevites. What he couldn't see was his own idolatry, his own perversion. So the question is, in which direction does your self-righteousness lean?
Thankfully, while our self-righteousness reaches far, God's grace reaches farther. And the good news is, that it reaches in both directions!