Best thing about a villain is to have a believable goal they can achieve, but also justifiable, something you could be convinced is a good thing, maybe the player can be swayed to join the villain.
Villain should be trying to make the world better, at least from their point of view.
Villain should be telegraphed (The player should hear about the villain, learn what they are doing, see the result of their actions upon the world.) Villain should not be a surprise that pops up at the end.
Uncertain that the villain should be encountered before the end though, this usually leads to the villain being invincible and getting away, and Cain doesn't like that. If the villain appears early, account for the player killing the villain early. Another option is the villain contacting the protagonist via videocalls or intermediaries that talk on the villain's behalf.
Fallout had a great villain in the Master, you hear about mutants, then you encounter mutants, then you learn they are hunting vaults, and then you encounter the Lieutenant, who will mention the Master has a plan. You can fight him, you can nuke him, but you can also convince him he is wrong. Cain refers him as 'two people in a computer glued together'.
In Arcanum, you learn about Arronax, hear you have to stop him, meet him, then you realize the real villain is Kurghan, who explains his reasoning. Cain obviously thinks he is crazy, but likes that he has a plan, can enact the plan, and thinks it is for the best.
In Outer Worlds, you pick the villain, it's either Phineas or the Board. Think it's interesting that most people think the Board is the villain, and is surprised at that. Says that Phineas forces you into doing what he wants, and his plan is risky and requires a lot more people to eat into the colony's limited food supply, and could lead to the end of the colony. The Board's plan, if it succeeds, still saves everyone. If it fails, it just leads to a part of the population shifting into cryostorage. You decide which one is good and which one is evil, and then you fight them.
Cain thinks Temple of Elemental Evil did a bad job with the villain. Zuggtmoy is poorly telegraphed, if he could go back to it, you would learn there is some big evil inside the temple, talk to the Circle of Eight or study their records. Talk to the elemental temples, maybe join them, maybe even unite them if you have high charisma skills and use them against Zuggtmoy, would have made her surrender option/joining her make more sense.
TL;DR: Bosses are good for encounter fights, villains drive story. Good villains are telegraphed, have a plan, player learns more about them in their travels.