What goes into a good villain?
Any good story needs not only a good hero with flaws, but a good villain with virtues.
Most people would read that and think, “A villain with virtues?! WHAT SORCERY IS THIS?!”
It’s true, though — just as your hero has to have flaws to overcome, your villain needs to have justification that slowly ebbs away. If you’re going to tell a moral tale — and, “enlightened” 21st century or not, that’s what readers and viewers want, is a simplification of good and evil — you have to start with moral ambiguity between hero and villain, then distill their moral vs. amoral/immoral conflict down to brass tacks.
But at the beginning of that arc, your hero must have a touch of evil, and your villain must have a touch of good, even if the villain’s good is nothing more than good intentions.
Find your villain’s good intentions, and you’ll find your hero’s dilemma. And that is essential for good storytelling. A hero unchallenged by himself as much as by his circumstances is a hero untested — and the story is all about testing the hero.