That $77B that is now returned to shareholders can be spent on whatever those shareholders want. It isn't really Apple's money to begin with... kind of the issue with being a public company. Unless of course its shareholders would look at that investment as sound, which might be a stretch given Apple's lack of background in any of those fields (maybe carbon capture given they have a great understanding of their supply chain and could already be thinking of ways to reduce their energy impact)
Well, 85% of the $77 billion, anyway.
Apple and its shareholders are the same entity when discussing “whose” money it is. If shareholders want it used to do buybacks, they vote for company leadership to do that. If they want dividends, they vote for company leadership to do that. If they want to invest in travel to Mars, they vote for leadership to do that.
Saying Apple’s money belongs to shareholders is a meaningless statement. It belongs to the collection of shareholders as a whole, who have opted to elect in leaders to decide how to spend it.
Only if there is an option to do that.