More often that not, the bad guy is the story initiator, while the characters (and the players) drive the story from that point. But what happens in the characters fall behind and make a blunder with their attempt to stop the villain? What happens (to the campaign, to the world, etc.) if the characters drop their quest to stop the villain, searching instead of other hooks and side-quests?
What happens in the bad guy wins?
Let's think about Emperor Palpatine as an example. What would have happened if Luke and his friends (the characters in our fictional tabletop campaign) failed to stop him, or more interestingly, didn't even care? What if they were happy staying at the Mos Eisley Cantina, enjoying the music and the occasional bar-fight, coming out for a short hack-n-slash skirmish with imperial forces or strange aliens?
As the DM, you could force the storyline you prepared down the group's collective throat, but that would just make the players feel like you're forcing a pre-generated script on them. They won't feel as if they are in charge of what's happening to them.
A better solution would be to let the bad guy have his way. As long as his way does not include total annihilation of the entire galaxy population, the campaign can still go on (and I can see ways for it to work even if the goal of the bad-guy is total annihilation...).
The key element that will allow you to do that is to ask yourself a single question about the villain:
Why does he (she/it/they) do what he does? Why trying to rule the world? Why trying to kill a god? Why spreading war and disease or do any of those things done by villains?
If you (as the DM) can answer that question, that the campaign does not end when the bad guy wins. After all, winning was all part of his plan - the first step in his plan.
What if Emperor Palpatine - using his dark side of the force powers - learnt of a threat to the galaxy, a threat so dire that he needed a strong dictatorship that will last for eons in order to prepare mankind?
What if he was planning to war another galaxy?
What if he planned to become a god made of raw force power?
So you see - even if your entire campaign was designed so that the heroes will stop the emperor and his brutal ways, after he wins, they get to see his real plan. Depending on the reasons for which he was allowed to win, you can design his real goal to better fit the players taste or abilities.
If the players ignored your story because it was boring for not enough engaging, its an opportunity to stop and think about what can you do to make them more engaged and interested.
If the players allowed the emperor to win because they fumbled in their way to stop him, because they made the wrong decisions or (and it happens) ran out of luck in critical moments in the story, now is the time to present another challenge and show them that they still have a chance.
If you like, instead of why? you can ask yourself and then what?
- Apple's stock will reach 1000$ per share. And then what?
- Microsoft's new operating system will be installed on 95% of the world's desktops. And then what?
- Android will take over the tablet market in 5 years. And then what?
- True AI will be created before the end of this millennia. And then what?
- D&D Next will be the most successful RPG system ever. And then what?
Just remember that your villain current goal is just the first step in his plan, and the campaign lives on even if he wins.