Actually, if you look at the stock trend, MSFT stock has been on a downwards spiral for the past few months, having lost 30% over 6 months. There's a slight rebound as of late, but the trend isn't looking good even if the stock value is still high. I wouldn't claim that MS is doing "very well", I'd be cautious if I had MSFT stock. Nothing lasts forever, not even for MS.
As to Windows, they have lost a lot of market share, mostly to mobile OSs (Android, iOS) due to changes in user habits, and a significant chunk to macOS, which is on the rise. Linux is of course still a small fraction for desktop use (but a large majority for server and performance computing), and yes, it's probably better this way.