A self-righteous person acts superior to his peers because he believes his moral standards are perfect. This "moral smugness" is condescending by nature and is usually found offensive by others.
Self-righteousness is a way unintelligent and nonathletic people can retain a sense of superiority. Various cults and religions promote self-righteousness in an attempt to convert the average person, who feels immoral by comparison.
Joe: Hey, I downloaded this awesome movie! Want to go watch it?
Tim: You DOWNLOADED it?
Tim: *Sigh* That's immoral and against the law. I would never do that.
Joe: You're a self-righteous tool.