Download the game service repair tool:
https://aka.ms/GamingRepairTool
After downloading, run it and wait for the repair to be completed. When finished, check if the issue persists.
The link above is a direct link to a repair tool; if you prefer, you can download it through this article:
https://support.xbox.com/help/games-apps/troubleshooting/gaming-services-repair-tool
If the problem persists, I suggest you try repairing your Windows using Windows Update;
https://support.microsoft.com/en-us/windows/fix-issues-by-reinstalling-the-current-version-of-windows-497ac6da-7cac-4641-82a5-f50398d879a0