Download the Gaming Services Repair Tool:
https://aka.ms/GamingRepairTool
After downloading, run the program and wait for the repair to complete. Once finished, check if the error persists.
The link above is a direct download link for the repair tool from the Xbox support article, but if you prefer, you can download it via this link:
https://support.xbox.com/help/games-apps/troubleshooting/gaming-services-repair-tool
If the error persists, click the Start menu, type PowerShell, and open it as administrator.
Copy and paste this command;
get-appxpackage Microsoft.GamingServices | remove-AppxPackage -allusers
Press Enter, copy and paste this command;
start ms-windows-store://pdp/?productid=9MWPM2CQNLHN
After that, check if the same error persists.