Here is an interesting tidbit in Psychological Science from Jordan and Monin. They suggest we protect our own self image by feeling morally superior when we otherwise might feel foolish.
When people's rationality and agency are implicitly called into question by the more expedient behavior of others, they sometimes respond by feeling morally superior; this is referred to as the sucker-to-saint effect. In Experiment 1, participants who completed a tedious task and then saw a confederate quit the same task elevated their own morality over that of the confederate, whereas participants who simply completed the task or simply saw the confederate quit did not. In Experiment 2, this effect was eliminated by having participants contemplate a valued personal quality before encountering the rebellious confederate, a result suggesting a role for self-threat in producing moralization. These studies demonstrate that moral judgments can be more deeply embedded in judges' immediate social contexts—and driven more by motivations to maintain self-image—than is typically appreciated in contemporary moral-psychology research. Rather than uphold abstract principles of justice, moral judgment may sometimes just help people feel a little less foolish.