That's true, but the shareholders have delegated the decision on how to spend the money to their legal representatives on the board. There's a strong presumption that the shareholders have elected board members whose decisions they support, so if the board makes decisions and the shareholders don't vote them out, those are presumed to express the preferences of the shareholders. Note that those decisions do not have to maximize shareholder profit. Shareholders can elect board members who commit to maximizing shareholder value, but they can also elect board members with a variety of other preferences and ideas about how to best run a company, or how to best spend its cash on hand. The board can legally pursue a wide range of strategies, and shareholder lawsuits basically never prevail (in the U.S.) absent some kind of overt wrongdoing, like secret side deals made by board members or something like that, or else shenanigans related to mergers and equity (e.g. some kinds of dilution).
I tend to think of it as the board being in possession of the company that the shareholders have all but signed over to them; with shareholders retaining notional ownership, mainly enforced via the rarely exercised right to revoke the delegation of power if they get sufficiently angry.
So, the clarity you've added here is neat (I hadn't drilled down into the specifics of what "fiduciary duty" meant in law, and also had been using "maximize shareholder value" as a shorthand for it), but if you search, you'll find lots of instances of boards being sued for breaches of loyalty over company business decisions. Courts seem to find lots of ways to connect the dots between "putting the interests of the corporation first" and "not signing off on dumb business decisions, like giving the CEO a huge raise in a year where the company missed its numbers".
Regardless; Apple is not going to space, at least not until it can figure out how to make money doing it.
Board members and executives have a fiduciary duty. Executives and board members who knowingly and willfully undertake actions that decrease the value of the company can be held personally (financially) responsible for those actions. (That's why you purchase director's and officer's liability insurance.)
They have an extremely vague "duty of care", i.e. to run the company in a manner in accordance with the wishes of the entities they serve as representatives of. Beyond that, they don't have any specific obligation; shareholders can, at least in principle, have many different wishes, and so elected board members can represent a variety of positions, from an aggressive profits-uber-alles position to some kind of safeguard-the-brand-reputation-for-generations viewpoint.
The main enforceable obligation is a negative one, to not actively do things that benefit themselves at the expense of the corporation they oversee, e.g. by making decisions primarily designed to enrich themselves personally. Almost anything that isn't active wrongdoing is defensible though; if a board member thinks in good faith that doing X would enhance the goodwill towards the Apple brand, and in good faith thought that prioritizing brand goodwill was the best long-term strategy, it would be fine to undertake a short/medium-term money-losing course of action to pursue the strategy. Courts generally defer to board elections to resolve those kinds of disputes over strategy, since courts are very bad at predicting whether a given strategy is actually in a particular entity's long-term interests.
Insurance these days is more often directed at government regulations than shareholder lawsuits; board members have various possibilities for personal liability if their company is doing illegal things on their watch.
That is to stretch the definition of ownership quite a lot. Share holders have no rights to or control of any portion of the cash balance of a company that are not granted to them by the board.
The board represents and has a fiduciary duty to the shareholders. The term "fiduciary duty" is not abstract; it has legal force, hence the frequency in the news of another investing term: "shareholder's lawsuit".