Let's talk about a few of the archetypical BBEG types, what to avoid, and some things you can always try.
Done to Death
The quest-giver that started the party on the quest was the BBEG all along!
Never, ever do this. It's the most unoriginal, laziest way of writing the BBEG, and worse, it's been done by everyone, including me, as it would happen. Today, I cringe at this writing trope, but I still remember why I thought it would work. In a good story, the villain should be accompanied by a nasty twist, and what better way of doing that than making the characters complicit in his scheme! It's a really thin ploy, and if even one player sees through it, the characters can simply walk away and sabotage the entire trick. Worse, you as a DM feel like an idiot, because your players guessed the twist before it even started.
There're other examples of poor villains that you should avoid. Like the mad cultist that just wants to blow up the world (because reasons). Or the crazy god of craziness that wants to mess with the players (because reasons). Or anyone else that doesn’t really have a motivation.
Character and Adversary
Creating a BBEG is a balance between making them compelling and making them intimidating. This is the beauty of all great villains; as much as your characters need to stop them, your players want to know them or to be them. So, the question becomes: how do I write a compelling character? If I could answer a question that monumental in a blog post, I'd have a Pulitzer, but I might be able to provide some very general tips.
Make sure your BBEG has a motive for his end goal that would make sense to a regular person. Why would a BBEG ever want to blow up the world? He lives there too! Furthermore, how can someone who is completely mad and has completely incomprehensible motives able to execute detailed and effective plans? Even if you can find a suitable reason for your BBEG to want to pull of an insane, self-destructive plot, that doesn't make it compelling. Your players should be interested in the BBEG character's logic and his way of viewing the world.
In addition to being an interesting character, you need to make this character intimidating. Of course, this doesn’t mean your BBEG needs to be able to fight the PCs himself; he has minions for that. But his presence, his minions, his plot, or his character interactions needs to bring a sense of dread to the table by threatening the PCs in some way.
Meeting the BBEG
If you can manage an interesting BBEG, it's important that you present this character in a way that allows your players to engage with him. In a movie, to characterize a villain, you can simply represent the villain in a room without the good guy around, and show him being evil without someone to reprimand him. Often this is called 'Kicking the Dog', since a villain hurting an animal is good signpost that he's the evil BBEG. But this doesn't work so well in an RPG, where switching perspective away from the Player Characters removes their agency. Basically, "cut-scenes" are weird in D&D.
You could always allow the PCs to meet the BBEG face-to-face, but not immediately fight, as you put some contrived method in between the players and their enemy. Sometimes, they're captured, other times, the BBEG is just a hologram, but always it steals the player's agency. Really try to avoid situations like this.
Lastly, you can just allow the villain to disclose all the information of his plot at the last minute, before the players have a chance to fight him (a plot exposition). This is just a painful method of storytelling. Look at the classic James Bond villain trope: the BBEG explains his entire plan to the hero near the end of the film, when the two characters first meet, all for the benefit of the audience. It's nonsensical, clumsy storytelling, and it can put your audience to sleep.
Thankfully, as the Dungeon Master, you have a number of tools up your sleeve to help explain the BBEG and his motivations. You can present "flashbacks" to the BBEG through NPCs that might have known the BBEG, or which have witnessed firsthand the his evil ways. You can present related organizations that act on the his behalf and menace the PCs with smaller quests that explain the his plan. You can reveal crucial information in a player's backstory is directly related to the BBEG in a telling way. You can even write the world around the BBEG.
A Practical Example: Thralmar
One of my favorite villains: Thralmar, was mostly stolen from an article on Wizards of the Coast, which I'm fairly certain is no longer hosted anywhere.
He was a half-beholder. Noone knows how he came to be, but he was the half-blood king by default. For the most part, Thralmar looked human, but each of his palms contained a large eye, which could open and produce a beholder's eye ray. Unbeknownst to most, he could also radiate an aura of antimagic, just like a beholder's central eye. Perhaps most dangerously, he was a skilled diplomat and manipulated the government to do his bidding while he endlessly schemed.
Hate looks like a beholder. They are creatures of hate for all other creatures, even other beholders, and Thralmar was no exception. He hated everyone else, and he hated himself. He wanted to conquer the world, and he wanted to destroy the world. Sometime he didn't know which one he wanted more.
Thralmar quietly raised an army of the discarded people from every nation in the realms: bastards, half-bloods, and the impoverished. This group, the Bastard Horde, was how the party first encountered Thralmar's influence. When the party became a problem for the Horde, Thralmar himself intervened, sending his top lieutenant to handle matters. Later, on several occasions, they met a mysterious young girl, who proved to be illusion than real. Though a series of stories and magical illustrations, this girl revealed that she was the sister of Thralmar (though it's not entirely clear if she was a physical twin in the traditional sense. Magical births are weird. ) She spoke of his motivations and his goals, and how the party might be able to stop him.
While the Horde set about accomplishing his goals, Thralmar arranged for wars to be fought, so there might be a distraction for his real plan: excavation of an ancient city containing a powerful spell, Apocalypse from the Sky.
How the campaign progressed from there is a story for another time. Thralmar was a fun villain, and one my players remember fondly.
- - -