Because they develop some of their core open source products right on top of GitHub. Visual Studio Code, .NET Core (and dozens of core libraries for .NET / .NET Core) as well as the less popular things they work on in the open.
See their GitHub for more:
https://github.com/Microsoft
Also their focus is now on developers. They made VS Code completely free, MIT Licensed and not for themselves, but for developers.