It happens to all of us. We put a ton of work into the lore of a unique villain and the heroes come in and trounce them in a round or two. It’s doubly annoying when the heroes fail to uncover all the cool lore associated with them. Fortunately, D&D is a game of magic, and there are several ways for you to treat this as nothing more than an inconvenience.
The entire undead creature type is a testament to unfinished stories! Did the fallen king, knight, or warrior fail to overthrow the current government and save their people from its tyranny? That sounds like a Death Knight waiting to happen. Did the cultist, archmage, or priest die before the ritual was complete? No big deal if they had steps in place to become a lich or mummy. That’s not even accounting for creatures like ghosts, banshees, and revenants which are generic ‘didn’t finish what we wanted’ or ‘we were wronged and are angry’ types of creatures.
If any of that takes away the unique flavoring of your villain though you could simply boost the difficulty of the creature in a way you find appropriate, give them the Undead Nature trait (the creature doesn’t require air, food, drink, or sleep.), simply say his hatred stopped him from passing on and call it a day.
You could instead double down on their death. Accept the fact they weren’t strong enough and vow to make them harder, better, faster, and stronger. Have an ingenious lackey harvest what they can from their deceased master and use it as the core of their new creation. What’s scarier then an Iron Golem? An Iron Golem with the magical capabilities of an archmage! Did your evil warrior get killed by the wizard spamming fireball? Cram their soul into a Helmed Horror and kiss your fireball woes goodby.
There is something magical about transforming an NPC into a literal death machine with a unique hatred of the player’s characters. Just make sure that the machination they are grafted to has features designed to handle a few of the player character’s more egregious combat abuses. Like a net blaster to ground annoying flying characters for example.
Villains often make pacts or swear vows to cosmic beings who have an interest in the villain’s success. Pacts with devils are common in D&D so it makes sense that your villain could have made a deal with one. When the villain entered hell there is nothing stopping you from saying that he rose quickly through the ranks to become a devil of reasonable power. They then can return to the material plane to finish their interrupted plans. This could also work in the opposite direction. Maybe the villain was a misguided ‘good guy’ that was sent to the celestial realm, was promoted to some rank of angel, and also returned to the material plane to finish their quest. Using celestials as villains is just delightful.
This particular change for the NPC is uniquely nefarious since devils and celestials can only canonically be killed on their home plane, and are just merely banished for a period of time when slain on the material plane. This allows you to recycle the villain for an extended period of time.