Occasionally I see comments about some company hoarding cash, often in a Keynesian context of how much better the economy would be if these companies would just spend everything they could.
But I don't think that's the relevant factor. It's probably more useful to think of it in terms of raising money in the credit markets. Companies don't have particularly smooth cash flows: Some quarters are better than others, and expenses can be quite uneven if they include big-ticket items like land purchases or acquiring other companies.
Many companies can borrow easily, particularly banks and bank-like entities with liquid collateral. But places at the other end of the spectrum (tech companies, for example) can't borrow as easily: the interest rates are higher, and it's harder to borrow at all.
So they do the next best thing: They retain some of their earnings (instead of paying dividends or some such), and invest that in the short-term money markets. In doing so, they buy the finance flexibility of a higher credit rating. Instead of borrowing at the last minute, they sell liquid securities, or just don't roll over short-term loans. So, to a degree, differences in borrowing ability or willingness to move investments around get arbitraged away.
This isn't just limited to companies: China's amassing of huge foreign-currency reserves could just be a workaround for the fact that foreign lenders aren't eager to loan into a less-transparent economy with a local currency.