This particular villain was a powerful wizard whose wife suffered from a terrible illness. He had tried, and failed, to save the life of his wife with magic, and then finally turned to the divine powers. Unfortunately, it was too late. He had always thought divine magic was useless, and that the so-called gods were abominable.
He resolved to end them. All the gods, everywhere.
He created an epic version of dimensional anchor, and inverted it. Nothing extraplanar could enter the material plane. Even going to the etherial plane was difficult. As a result, the gods were cut off from their main power source: mortal prayers. Even souls could not reach the afterlife. He knew the gods would eventually weaken as they used power they could no longer regain.
He built a machine that would drain power from wizards, and did it to them all. Every wizard, one at a time, was kidnapped and drained by the machine. He harvested them, gathering their power to use in a ritual that would (he hoped) grant him more power than any of the weakened gods. He planned to wipe them out, seize their remaining power, and use his ultimate power over life and death to cure his wife. Ironically, in his studies and spells, he eventually gained an effective Divine Rank (though he never realized it).
It took centuries to capture and kill all the remaining wizards, during which sorcerers became the sole arcane casters, with occasional brilliant fools venturing down the wizard’s path (only to vanish, once their powers had grown enough). Eventually, he began taking the most powerful sorcerers as well, though he didn’t get nearly as much power from them.
As his plans neared completion, he allowed a wizard to live, growing in power, far beyond when he normally would have taken him. He sent his apprentice (the last in a long line of apprentices, who all got fed to the machine eventually) to join the other wizard and found a new wizard’s academy, and a new crop of wizards.
The non-apprentice wizard was a PC. Many students were found for the school, and the PC’s wizard became quite proud of their accomplishments.
Then, at a climactic moment in the campaign, which led directly into the final arc of the story, The Wizard harvested his crop. In a single night of fire and blood, the finest accomplishment of the PCs was wiped out by the same villain who had steered them towards it in the first place. The PCs had never even suspected his existence, and had only a cryptic clue as to who or what he was.
Farlaghn, the only god who had been on the material plane when the locking spell was cast, spent those centuries finding heroes, whisking them away to a timeless staging area seconds before their deaths. He knew that the Academy had given The Wizard most of the remaining power he needed. He recruited the survivors of the Academy to find several relics that could be used to create a portal to The Wizard’s stronghold. At each step they were opposed by a lieutenant of The Wizard, all of whom were returning villains that had a close, personal tie to one of the characters. All the lieutenants escaped with their lives, and the PCs powers grew (as, of course, both Farlaghn and The Wizard wished).
The PCs? They ended up leading the army of legends against The Wizard and his lieutenants, so the party could face off against him. With seconds to go before the ritual that would empower The Wizard with the strength of a million fallen wizards, and spell the downfall of all gods, the party disrupted the spell that had preserved his wife at her last moment. She died and killed him in the process – he had linked his life force to hers to keep her alive.