If you ever worked on any big corporation, it becomes crystal clear why things suck. Megacorps value money first, second, third, fourth and fifth. Sixth comes avoiding being caught by their crimes.
So, Microsoft doesn't have a vision for Windows as an operating system, it sees Windows as a way to maintain a stranglehold in office computers the world over. It doesn't matter that most people on lemmy will say "switch to linux", they're not companies, they're not bosses - these are the vast majority of Windows users and South America + Asia + Africa make up a fuckhuge market. Sure, Europe and USA have more money, but the rest have sheer numbers.
Another thing that matters a lot is that many decisions come from the top and are enforced. If Satya Nadella or the director of whatever bullshit says something, those below have to comply. If the order from above is "cram bullshit ads in Windows Explorer, this has the highest priority", that has to happen.
Regarding resources, having them and allocating them in a decent manner are not the same thing. The same could be argued about USA having trillions of tax dollars and having so many people living in poverty without healthcare or even basic education. Lots of that money go to keeping their armed forces. Microsoft is not too different, they have to pay people who keep their datacenters up, pay for the energy of said datacenters, maintain several other apps they have - oh, and the CEOs bonuses, because he's such a great leader who totally deserves billions every year!!!!! Of those 300bn, how much are they diverting for Windows in general? 50b? 20b? 1b? Of that, how much is going straight for security, bug tracking and quality assurance?