Human self-righteousness is directly related to pride- an inordinate desire or view of one’s own excellence, an over-estimation of one’s own worth, to roughly quote Aquinas. But from that position all kinds of thoughts and behavior can be justified in our minds, from gossiping to lying to stealing to taking revenge for some perceived wrong, to beheading “infidels”.
To ‘prefer ourselves to God’ (an aspect of Adam’s basic original sin according to the catechism, is to simultaneously prefer the *truth *to be what we like; Adam’s sin of disobedience began with believing a lie over the truth, by believing the serpent over God. This set him apart from and above God for all practical purposes in terms of authority over his own morality-and this is the essence of pride. But while ushering in the New Covenant when the time was ripe in history Jesus reveals that apart from Him (from communion with God), we can do nothing (John 15:5).
Humility is part and parcel of faith, hope, and charity, which is why it’s so highly exalted and takes such a central role in the gospels. It, humility, is what none of us have enough of. Pride opposes humility, and God opposes the proud according to Scripture. And it, humility, is what Jesus demonstrated throughout His life but most especially on the cross: God is, amazingly, humble, while, when we “play God”, we’re generally just the opposite.
Human pride/self-righteousness is an ugly thing which resides behind every sin in one way or another. Humility before God and union with Him is the answer; love blossoms as a result and sin becomes excluded by its nature. “You shall love the Lord your God with your whole heart, soul, mind, and strength and your neighbor as yourself.” That’s the goal for all of us, with the purpose of our righteousness being God-based, as it was always meant to be, rather than man-based with self-righteousness being the outcome.