Hi Mehdi,
Each third-party app adds files and registry keys in different branches of the registry, and Windows can't tell which file or registry entry was added by which app.
Microsoft already has a tool that can remove the broken or leftover installer registry entries. You can read more about that tool in the following article:
Fix problems that block programs from being installed or removed - Microsoft Support
Note that the above app doesn't remove orphaned COM registrations or file associations. Registry bloat from leftover apps doesn't cause much of a performance hit because most app-related registry keys are queried dynamically rather than cached in memory. Hence, such a cleanup tool may not be necessary.
Given this situation, why doesn’t Windows provide a built-in tool or feature that can safely detect and remove leftover files from uninstalled applications?
Unfortunately, there is no way for Windows or any third-party cleanup tool to know which files are leftovers. But if you wish to make a feature request to Microsoft, please use the Feedback Hub (Win+F).