Heroes and villains are essentially two sides of the same coin. The hero is the upholder of a society's values, the villain the breaker of said values. Our fascination with the villain is, in many way, our fascination with defying our own society and the order of our lives. The best villains are the ones that might have been us had events gone differently in our lives or had we given in to a moment of rage, of desire, of weakness.
Take the phenomenon of the villain monologue. Ever notice that most of the time the hero doesn't really have a good comeback? A few heroes might do a Shut-Up-Hannibal and punch the guy while he's still talking, but most of the time the hero responds with some thin gruel about the villain being insane or evil or "defier of the social order," as if what the villain is saying must automatically be taken as crazy talk. It isn't always black and white, and it takes a good writer to show that while a villain may be bad, he isn't necessarily wrong. A true villain doesn't just jeopardize life and liberty; he forces you to consider why you believe what you believe.
Example: In "The Dark Knight," the Joker's premise is that most people aren't too far away from embracing anarchy. On the one hand, the Joker's final social experiment (the bobby-trapped ferries) falls through and shows that the people of Gotham City aren't willing to destroy each other. But then Harvey Dent turns into Two-Face and shows that, yes, even the best of us can fall from grace. So despite being defeated in the end, the Joker's argument isn't completely refuted.