PCs have a lot of foes in your campaigns.
Many of them are simply random monsters or minions. A villain is an opponent with much more complexity.
Of all the characters, villains are the most important you play as DMs.
You can find there five basic criteria to build unique villains.
Villains are opposing forces
No matter if the villain is an individual or a group, or a deity or a supernatural force. His role and purpose are to oppose the PCs and force them to make decisions.
The more difficult are those decisions the more more fun your players will have.
Villains are powerful
They can be solitary wizards, or clerics of an evil cult, or maybe a rich merchantile group. Whatever they are, villains have power (magic, divine, wealth, politic..).
They're going to use against the party and to make your players' lives difficult.
They may often have allies, servants, minions and lieutnants to cast against the heroes.
The more powerful your villains are, the more epic will be their defeat.
Villains are unsympathetic
Villains must be hated.
Players shouldn't fell sympathy for them.
If it so, it will weaken their strength as villains.
A less strength will bring less fear, then less danger, then a less heroic victory when the party will defeat the villain.
Villains have bad motives
Villains have always bad intentions: they can make crimes for their own benefits or moved by superior orders (a divine being...).
They have bad intentions even if their actions are legal (think about a King who orders extremely high taxes and starve his people) or viewed good by many.
Villains can also have needs so excessive that are detrimental to other people (think about a Lawful good cleric who believes she must convert to her deity all other people, with soft or hard manners).
Villains engage emotions
You players should hate the villain.
They should come around the table wanting to defeat him, either killing or putting into jail or banishing from the plane or whatever.
Strong emotions will surely fuel their want and they will have a strong purpose to play in your campaign.
Study how to increase their hate: the villain can indulge in heinous acts, or may oppose them at every step, making difficult to reach their goals, or may have directly affect their lives (killing friends or relatives, stealing magic or wealth...).
Create a "good" villain and your campaign will improve a lot.