Create an in-universe reason
There isn't really a mechanical solution for a character losing levels in 5th edition D&D. So I think NautArch's answer of just making it part of your backstory is the right approach. I would like to suggest some potential story reasons that don't break the player's suspension of disbelief.
You're out of practice
Class level is a reflection of a character's experience, knowledge and training. To me, it doesn't take much to believe that if a character didn't use this knowledge or training for some period of time that it would begin to fade. Much like real-life skills do if you don't practice them.
This changes the leveling up story from "gaining new powers" to "re-discovering what you once had". I think this could be a really enjoyable character story to play out.
You swore never use your power again
The loss of a loved one, a mistake that cost them dearly, any traumatic experience can work for this. For whatever reason that character has sworn off the use of the magic and abilities they had before.
I once played a character that was once a powerful ranger capable of fighting dragons, but he made a mistake that cost him his family and he walked away from the ranger life entirely. Slowly as the campaign unfolds he rediscovers why he wanted to be a ranger in the first place and allows himself to use more of the powers he once had. This story let me explore a very personal journey that was more about conquering his own demons then fighting external threats.
Something external took your power away
An encounter with a powerful being, a punishment from the gods, an illness or curse. Some external force took your power from you, now you are on a quest to get it back. Maybe you know what took your power, maybe you don't. Either way I believe this give plenty of story hooks for a DM to use.
With this version you are on a quest for vengeance, atonement, or a cure. Whatever it is, there is sure to be powerful story moments as you slowly weaken its hold on you, regaining your previous power.
These are just a few idea I could think of just from reading your question. With more knowledge of your campaign world and the character themselves I am sure you could come up with some suitable explanation for how your character lost the power the once had.
My advice is not to ignore or retcon. it but instead lean into it and use it as a basis for a powerful backstory with plenty of depth.