This depends on when we're talking about- because both companies have had their ups-and-downs for years. Apple is.... quite rich now to say the least. The main reason is likely this:
Apple is a primarily hardware-oriented company that cut a niche (keyword niche) market in the computer and technology world and for years has catered to a comparatively smaller, dedicated group of followers. Only in the last decade or so has it become as mainstream as it is now. For years, while Microsoft was dominating markets, Apple was clinging on for dear life.
Microsoft is a primarily software-oriented company which wanted to develop and sell an operating system to the users of every computer on the planet. The fact that they nearly succeeded at this means: the majority of PC computers ran Windows, and once that happened, everything about those PCs and the software they ran catered to Windows. So whenever a new Windows came out, most of those people were going to buy it. They basically got an enormous market share and they kept selling to it almost exclusively for years. Add this to their incredibly wide-ranging attempts to break into other markets (like with the Xbox, when the world scoffed at the idea of Microsoft trying to make a console) and it makes sense they have large holdings.