If a company does not have excess cash, and/or has several good projects (NPV>0), returning money to stockholders (dividends or stock repurchases) is BAD.
Read more here: http://pages.stern.nyu.edu/~adamodar/New_Home_Page/lectures/...
Management is usually granted stock and/or stock options, which aligns their interest with the other stock owners.
A couple could be shareholders believe they have better uses for the money elsewhere and to keep management disciplined (i.e. too much cash makes management reckless).
Think about if you were a partial owner of two businesses. One business has a lot of cash but isn't growing. The other business is growing but doesn't have a lot of cash. As a partial owner, what would you do?
MS, Apple and Google are in different situation. They want to hold cash to protect and grow their network externalities. It's zero sum game in long term.
Article about their cash woes when they "only" had $120B to invest: https://www.theguardian.com/business/2012/oct/26/apple-inves...