I'd like to try the analytical approach here: to figure out what makes morally wrong characters lovable (assuming that this is the 'unexpected' outcome), start with morally wrong characters who AREN'T lovable, and figure out what's missing.
Or rather, characters that aren't supposed to be lovable...'lovability' is pretty subjective, but you can usually tell whether an evil character is written to be the kind you 'love to hate' or the kind you just hate. :T
I think, in a nutshell, those you should love to hate have lots of positive traits on top of their baseline badguy traits; while those you should just hate have far fewer...or maybe none. They're missing those enjoyable character elements-- charm, cleverness, beauty, creativity, humor, compassion, etc.-- that contrast with the bad ones and/or make them seem less important. Without them, you have nothing to focus on except the bad things that they do; so there's a lot less to love.
And this is slightly beside the point, but: to be honest, I don't really go for that idea of liking a 'bad' character because they represent something you can't have; 'unfulfilled subconscious desires' and fantasies and whatnot.
I love villains and 'morally wrong characters', but I don't dream of doing horrible things and suffering no consequences. I also don't wish that people would love me for hurting others. I just...don't. =/ My lifestyle and my enjoyment of a character are two separate things..
If there are cognitive processes at play here, my opinion is that they're the same ones that make humor work: expectations, and the subversions thereof.
People naturally associate likeable traits, like the ones I listed above, with goodness-- we tend to assume that someone who appeals to us is morally superior to someone who doesn't. What a (subconscious) surprise, then, to find characters who impress us and make us laugh and swoon...and yet, are not 'good'. They do very obviously bad things, and we have to reconcile that with how good they make us feel.
One way to do that is to find them funny. ^^ Or just fun, in a way that's unique to these kinds of characters.