Microsoft recently announced that they will submit some 20,000 lines of code to the Linux kernel under the GPL license.
The code makes virtual Linux machines run better on Microsoft's virtualization servers. So it may be argued that the code donated serves Microsoft's plans of global domination more than the general well-being. However, as Linus Torvalds, creator of Linux, says:
“I agree that it’s driven by selfish reasons, but that’s how all open source code gets written! We all “scratch our own itches”. It’s why I started Linux, it’s why I started git, and it’s why I am still involved. It’s the reason for everybody to end up in open source, to some degree."
Microsoft contributes to open source on several projects, mostly to ensure that the code runs well on the Microsoft platform. This is no different than many hardware manufacturers who release drivers for their products, like graphic cards.
The open source community is not "The Good", Microsoft is not "The Bad", they are both "The Pragmatic", trying to get the job done.