I went to an amazing session on writing villains by Allison Brennan, and came home with a ton of tips. This is the first:
Your villain must be better than your hero, otherwise your hero will look stupid. At the same time, your hero must be worthy of your villain, otherwise it won’t make sense for the villain to oppose him.
For example, think about Harry Potter and Lord Voldemort. There is no question that Voldemort is stronger, more powerful, and better at magic. Every time Harry faces him, the reader immediately wonders how Harry could possibly win. But at the same time, Harry did win once when he was a baby and that is what makes him worthy of Voldemort. It’s also what drives Voldemort to destroy Harry (because no one has beaten him before).