Hypocrisy, let's say, is when someone conspicuously advocates some particular moral rule while also secretly, or at least much less conspicuously, violating that moral rule (and doing so at least as much as does the average member of her audience).
It's hard to know exactly how common hypocrisy is, because people tend to hide their embarrassing behavior and because the psychology of moral advocacy is itself a complex and understudied issue. But it seems likely that hypocrisy is more common than a purely strategic analysis of its advantages would predict. I think of the "family values" and anti-homosexuality politicians and preachers who seem disproportionately likely to be caught in gay affairs, of the angry, judgmental people I know who emphasize how important it is to peacefully control one's emotions, of police officers who break the laws they enforce on others, of Al Gore's (formerly?) environmentally-unfriendly personal habits, and of the staff member here at UCR who was in charge of prosecuting academic misconduct and who was later dismissed for having grossly falsified his resume.
Now, anti-homosexuality preachers might or might not be more likely than their parishioners to have homosexual affairs, etc. But it's striking to me that the rates even come close, as it seems to me they do. A purely strategic analysis of hypocrisy suggests that, in general, people who conspicuously condemn X should have low rates of X, since the costs of advocating one thing and doing another are typically high. Among those costs: creating a climate in which X-ish behavior, which you engage in, is generally more condemned; attracting friends and allies who are especially likely to condemn the types of behavior you secretly engage in; attracting extra scrutiny of whether you in fact do X or not; and attracting the charge of hypocrisy, in addition to the charge of X-ing itself, if your X-ing is discovered, substantially reducing the chance that you will be forgiven. It seems strategically foolish for a preacher with a secret homosexual lover to choose anti-homosexuality to be a central platform of his preaching!
Here's what I suspect is going on.
People do not aim to be saints, nor even to be much morally better than their neighbors. They aim instead for moral mediocrity. If I see a bunch of people profiting from doing something that I regard as morally wrong, I want to do that thing too. No fair that (say) 15% of people cheat on the test and get A's, or regularly get away with underreporting their self-employment income. I want to benefit, if they are! This reasoning is tempting even if the cheaters are a minority and honest people are the majority.
Now consider the preacher tempted by homosexuality or the environmentalist who wants to eat steaks in her large air-conditioned house. They might be entirely sincere in their moral opinions. Hypocrisy needn't involve insincere commitment to the moral ideas one espouses (though of course it can be insincere). Still, they see so many others getting away with what they condemn that they (not aiming to be a lot better than their neighbors) might well feel licensed to indulge themselves a bit too.
Furthermore, if they are especially interested in the issue, violations of those norms might be more salient and visible to them than for the average person. The person who works in the IRS office sees how frequent and easy it is to cheat on one's taxes. The anti-homosexual preacher sees himself in a world full of gays. The environmentalist grumpily notices all the giant SUVs rolling down the road. Due to an increased salience of violations of the norms they most care about, people might tend to overestimate the frequency of the violations of those norms -- and then when they calibrate toward mediocrity, their scale might be skewed toward estimating high rates of violation. This combination of increased salience of unpunished violations plus calibration toward mediocrity might partly explain why hypocritical norm violations are more common than a purely strategic account might suggest.
But I don't think that's enough by itself to explain the phenomenon, since one might still expect people to tend to avoid conspicuous moral advocacy on issues where they know they are average-to-weak; and even if their calibration scale is skewed a bit high, they might hope to pitch their own behavior especially toward the good side on that particular issue -- maybe compensating by allowing themselves more laxity on other issues.
So here's the final piece of the puzzle:
Suppose that there's a norm that you find yourself especially tempted to violate, though you succeed for a while, at substantial personal cost, in not violating it. You love cheeseburgers but go vegetarian; you have intense homosexual desires but avoid acting on them. Envy might lead you to be especially condemnatory of other people who still do such things. If you've worked so hard, they should too! It's an issue you've struggled with personally, so now you have wisdom about it, you think. You want to try to make sure that others don't get away with that sin you've worked so hard to avoid. Moreover, optimistic self-illusions might lead you to overestimate the likelihood that you will stay strong and not lapse. These envious, self-confident moments are the moments when you are most likely to conspicuously condemn those behaviors to which you are tempted. But after you're on the hook for it, if you've been sufficiently conspicuous in your condemnations, it becomes hard to change your tune later, even after you have lapsed.