Apple's responsibility is to its shareholders, and that responsibity is to maximize profits. Because it stands to lose billions of dollars in taxes if its income is reported naievely, it makes perfect sense for Apple to spend millions, tens of millions, or even hundreds of millions to optimize its tax flow.
As long as nothing illegal is happening, this is just an exams of a company fulfilling its fiduciary duty to its owners.
If people think this behavior is egregious and needs to change, the solution is to pass new laws to that extent. No one is going to voluntarily overpay on their taxes.