Their code used to be their core value and source of profit; they are open-sourcing a lot of it now because that's not true anymore and they might as well get some publicity out of it. If you look at companies like Google and Facebook who publish lots of open-source, you'll see the same trend --- it's opened because it's not worth anything to keep it secret anymore.
.Net Core brings MS's equivalent to Java to Linux and enables the use of a better language set (C#/F#) and allows for a relatively seamless development experience.
What's not to like?
I was unclear; their revenue streams are still overwhelmingly comprised of proprietary tech.
Darwin and AOSP are massive compared to the toys MSFT is throwing over the Linux wall. This idea that they need to lose money is a strawman.