How To Roleplay Villains Fairly
When portraying a villain, it's important to try to create an interesting and satisfying experience for other players, and to avoid frustrating them so much that they're ready to throw in the towel and go see what's on Netflix instead. Here are some rules to follow to help you do just that.
You must be prepared for your villain to face consequences. For example, if it so happens that the PCs end up capturing your villain and all are in agreement that the villain be locked up in a secure place, you should let them do so. You should not contrive a deus ex machina to save your villain, nor should you insist that the PCs take another course of action. If you're trying to ensure that an antagonistic presence remains in your RP, consider using villains who operate with a fault-tolerant system instead. If you're trying to ensure that you still have a character to play, then either make your character more tolerable to be around, or play a different character for most of the game.
You must establish limits to your villain's abilities and/or resources, and stick to them. Figure out the limitations of your villain's powers, doodads, and resources early on to prevent the character from becoming OP. Maybe your villain's shield might be able to block bullets, but not a rocket. Your villain's powers might require a cooldown or recharge period after so much use. Using something the wrong way or under the wrong circumstances may cause it to backfire in dangerous ways. Your villain might have limited quantities of a resource and so might have to use it sparingly. (See also Phlebotinum-Development Questions for a list of things to ask yourself to help you establish limits.)
There must be a way to defeat the villain, and this way must be reasonably available to the PCs. No pitting the PCs up against an invincible or untouchable villain. Your villain's only weakness cannot be something so rare or difficult to get that it might as well be the prime minister's toenails or a piece of the True Cross.
The means to defeat the villain must be possible to discover, if the PCs don't know it already. If the means to defeat the villain are currently unknown to the PCs, there must be a way for them to discover it using means within their access, such as through books, the Internet, or by talking to people who associate with the villain. You will not make your villain's weakness so obscure that it might as well be some ancient word that has been erased from all memory and record.
The method of discovering the weakness must be reasonably intuitive. It's acceptable for players to be able to find the weakness of an ancient demon in a book owned by a known monster hunter. Having the answer lie with a janitor who has never shown, let alone hinted any knowledge or interest in the supernatural is not acceptable.
Your villain must not be nor use anything that is not shown, implied, or foreshadowed in the setting or plot. For example, if your setting has been hard science fiction so far and there has been nothing to indicate the existence of the supernatural, your villain cannot be a mage. If your game is a CSI-like crime procedural where everything up to this point has been mundane and ordinary, the perp cannot have used extraterrestrial technology to commit the crime.
Your villain must not do or use anything that the PCs have no reasonable way of countering or avoiding. This means no attacks which cannot be dodged or blocked, no instant and unopposable binding, no instant and irresistible mind-control, and no snapping one's fingers to instantly turn characters into kittens.
Your villain will not avoid damage beyond reason. Although not every move made against your villain must succeed, your villain will not continuously and indefinitely block, parry, or avoid them all, particularly not when the PCs, whether individually or collectively, are on equal or superior footing to your villain.
Defeating the villain should not require you or your own characters to step in and take action. The other characters should have a reasonable chance of taking on the villain without needing to rely on the resources, muscle, or brains of one of your own characters, or for you to dump knowledge on the characters without them having actually done anything to find it for themselves (EG, "you remember that…" or "your instinct tells you that..."). Always give other characters the opportunity to figure out and do things for themselves. Keep assistance and interference minimal, and even then, only give it when it's actually requested.
You will not use "but it's canon!" as an excuse to ignore any of the above rules. Canon or no, unfair play is unfair play. If your villains don't meet the above standards, either retool them or get new villains.
Also, take a look at:
Basic Tips To Write Better & More Despicable Villains
MORE Tips To Improve Your Villains
Mindsets & Rationales That Lend Well To Villainy
How Good People & Well-Intentioned Groups Can Go Bad
Changing Alignments, Allegiances, & Loyalties More Believably
Tips To Write Better & More Exciting Action & Fight Scenes