Turning good guys to bad and vice versa or writing characters that are a hearty mix of both has always been a favorite pastime of mine. People were convinced Ty was the hero of TYGERS until about 4 scenes in, when I turned the tables and showed them a 4 y/o boy's best friend was a psychopath instead of his hero, which completely freaked one reviewer for a few chapters. OTOH, Mik, Jorg/Veriel, and Jurel all started out as villains, but when you got to see from their POVs...well, how about that? Not villains anymore...or at least villainous heroes, in Jorg's case. At the beginning of PROPHECY, people were convinced Joe was a stalker. Perception is a fun game to play.
So, how do you do it? How do you make a villainous character engaging and appealing to the readers?
First of all, the character has to be three-dimensional. A two-dimensional villain will automatically be disliked by readers. That's the point of a villain. To be three-dimensional, a villain has to have a backstory and reasons for what he/she does. Those reasons have to have a logic, even if that logic is skewed.
You have to make the reader empathize with the character's position...not necessarily sympathize with or agree with or even approve of the choices morally, but empathize with and understand why and how this happened. One way to do that is with sympathy. People who are seriously wronged and seek revenge is a good way to invoke the knee-jerk support or sympathy of readers, but it's the cheap seats of doing the job.
What else works?
Alien or non-human sensibilities. Write a were or animal-type paranormal creature, and you have instincts in the mix. You can also have instincts for creatures like vampires. Write someone from a culture not our own, and you have cultural mores, ethics, and laws that call for things we wouldn't engage in and might find horrific. Write a creature driven by hunger, and everything will be flavored (pardon the pun) by that driving need.
World situation. Men will commit atrocities in a war that they never would otherwise. I'm not saying war corrupts absolutely. It doesn't, but... A friend of mine (the wonderful author Teel James Glenn) once gave me an old quote that applies here: "The rules of engagement only apply until the first attack." After that, it's fight or die, and any dirty trick that lets you live is fair game, in the heat of the moment. I can't recall the movie, but there is a great scene of Russian soldiers being sent out (WWII, I believe). There were only enough firearms to supply one in ten of the men, so you'd stay close to another soldier and try to stay alive long enough for him to be shot, so you could grab his rifle. Whatever you did to stay alive was what you did. Was that ENEMY AT THE GATES? Maybe?
Likewise, people who are starving will choose the lesser of two evils, steal or die. Ethics are often situational, and the spirit of the law is not black and white. In a severe enough situation, people will rethink their ethics and are much more likely to slide toward neutral from lawful.
Politics. Closely linked to world situation. If you see something happening or coming that you feel is ethically bankrupt, what would you do to stop it? From the Declaration of Independence... "But when a long train of abuses and usurpations, pursuing invariably the same Object evinces a design to reduce them under absolute Despotism, it is their right, it is their duty, to throw off such Government, and to provide new Guards for their future security." It is often seen as a duty to right the wrongs, and if the despot is abusing his power, violence may call for violence. THAT is your Robin Hood character, in a nutshell. No, he wasn't a murderer, but he didn't shy from killing a few soldiers, when he had to. That bow and arrow or long sword or staff weren't for show, after all.
Protection of the innocent. This is another lesser of two evils moment. If you had a choice to stand by silently and allow innocent children to be hurt...whether they were your children or not...you may be spurred to do something extreme in their protection.
Madness. Pure and simple. This takes the idea of revenge a step beyond. What if the abuse was so severe, the character went mad from it? What if, in his grief and pain, he does things that are horrible? It could happen, and I've found readers very receptive to the mounting madness in a character.
The mind of an innocent. What if the person doing wrong has a very childlike understanding of right and wrong? What if, in order to protect another, he does things that most people would consider the very WRONG choices, because he doesn't understand what the right choices are? What if the wrong is all he's seen? Or he's so sheltered, he's never faced the situation to know the right answer? Think SLING BLADE. Think DOMINICK AND EUGENE.
The horrific justice-bringer. There is a reason Hannibal Lecter is so popular with readers (including myself). "I only eat the rude." Look at who he preys on: pedophiles, serial killers, officious types, thieves, corrupt or abusive officials in positions of power... In short, all of the people many feel, deep down inside, the world is better off without. The people who are nice don't need to fear him.
However you do it, it's a rare and challenging writing feat to write the villain-hero or the likable bad guy.