There are a number of reasons that Microsoft could be investing in CyanogenMod. Android is a very open operating system. However, Google does not offer the source code for services like Gmail and YouTube. Google has also been tightening its grip on Android in the past few years.
Investing in CyanogenMod could mean that Microsoft's apps would become a much more prominent part of the operating system in the future.