“Thanks for the head’s up. I’ve had a lot of fun with you at the table so I hate to see you go. If there’s anything I can do to make things more fun or engaging for you let me know. There will always be a seat at the table for you.”
The reasoning might involve a lot of stuff outside the game, so, as others have mentioned, it’s probably best to leave that alone for the time being.
Consider making a point of hanging out in the next little while and consider a bit of a going away bash with the group.
Yeah I think that's about all you can say without knowing why they're quitting on a deeper level.
My personal experience is that things don't generally just "stop being fun", there are usually more specific reasons, even if they're not directly connected to the game. Pretty much everyone (touch wood) who has left my main group did so because they moved away physically, and at least two of them rejoin whenever they're in proximity!
But I do have a lot of experience of people stopping playing long-term multiplayer videogames. The main ones I can think of:
1) Overwork and obsessing about work and work being stressful kind of a destroyed a friend's ability to appreciate really any kind of "casual" or "fun" leisure activity. He recovered it eventually, but it took a long-ass time.
2) More positively, a good friend transitioned and she found that she was just no longer as excited by MMOs, and much more interested in physical fitness in a serious way (something she'd had little interest in before). I think, if I'm doing armchair psychology, maybe being a woman IRL meant there was less/no thrill to being one in a videogame, and with the right body, exercise felt more fun, but whatever the cause, it was good, even I've seen a lot less of her since (we're in different countries), because she seems hugely happier now.
3) Most ridiculous one - a guildie rather than a real friend, but I knew him a long time, declared games "weren't fun anymore" (echoing the OP's friend slightly, but maybe that's just the edit), and that he was done with them. We later learned this was because he'd got a new GF, of a somewhat stereotypically snobbish-ly opinionated nature, who took the view that all games were for children/teenagers, so it was her or games. When that inevitably blew up (because really, come on!), a few months later, he was back.
But unless the person is a close friend anyway, they're not likely to want to discuss the deeper reasons (except maybe if they come back). If you're aware of them, then you may have an idea if/when the person is likely to be interested in playing again.
I still think that it can't hurt to ask why. It just might be burnout on d&d. 6 years of 3 games a month is lots of gaming in one specific system and more or less same type of game ( no matter how you spin it, 5e is high powered high fantasy).
That is the one thing that might be worth asking about, I think. But the issue is that they might simply not know, they might just know they're not enjoying this - this is why I think it's helpful, even when you have a long-running campaign, to drop in the odd one-shot in another (easy to learn) system. You can gauge system burnout pretty well from that - like, if you have a player (or players) who are suddenly way more engaged, and then you know they may well be a burned out on the main game, and maybe that's worth thinking about.