GitHub source code is different from windows code though. This isn’t a moral argument but a dry legal one. Microsoft doesn’t control the rights for a lot of the windows source code because it isn’t their copyright to begin with. Meanwhile even private repos on GitHub are subject to uses like this through the terms of service iirc.
So from a moral perspective I’d agree with you, but I don’t see how this could fly legally. I’m pretty sure Microsoft has had six armies of IP lawyers independently come to this conclusion.
Terms of service does not mean the forfeiting of user's copyright. There is an argument to what extent snippets of code is fair use versus when it becomes excessive and violates the copyright.
You are right though, battling Microsoft in court will be no easy fight, and it will probably be a long one. However, I think the sharks are in the water and smell blood (money), as many lawyers see weaknesses in Microsoft's arguments and justifications (excuses).
You here run into other problems though with people mirroring code on github that they do not have the rights to change the license for, which would be required for accepting the terms of services. E.g. if you take a GNU project hosted at Savannah and maintain your own independent for of it on github for whatever reason, you cannot re-license the bit that is own by the FSF to conform with the github ToS without getting the FSF's permission (and for other projects without a single copyright holder, every single contributor). This ofc isn't Microsoft's or Github's fault, but the people making the github repo, but still creates a problem for breaking licenses.
Their FAQ also has some ambiguity on what it has been trained on:
> It has been trained on natural language text and source code from publicly available sources, including code in public repositories on GitHub.
> Microsoft doesn’t control the rights for a lot of the windows source code because it isn’t their copyright to begin with.
I know "we don't own the source" came up before with OS/2, but I'm pretty sure Microsoft owns the bulk of Windows source code (maybe not in the hardware drivers department), but as I mentioned in another comment, it has trade secret protection, they simply have never published or licensed it.
I feel that it's important for this discussion to point out that the actual GitHub source code is AFAIK (mostly?) closed source, unlike for the open core GitLab. (No idea whether it's crawled by Copilot ?)