Self-righteousness comes from judging the world by the perceived correctness of actions rather than by the quality of outcomes.