Unfortunately, the obligations of a corporation are such that they have to maximize profits. Avoiding taxes in those ways is not illegal, so big corporations are obligated to do it.
Couldn't the shareholders dismiss the Board of Directors if they deem they are making decisions that are not in the best interest of the share price?
Let's be honest, if Facebook decided to give back their $430 million tax credit and pay 40% on their $1.1 billion of profit, their share price would take a major dive.
Do you think the board would not be dismissed?
(Same goes for Apple, Google, etc. etc.)
http://www.forbes.com/sites/robertwood/2013/02/19/tax-increa...
The maximize profit argument is not an absolute imperative, and is often used to justify bad behaviour.
What happens when you don't sold your product in the US? Why does the profit of Apple selling an iPad in UK have to result in them paying taxes in US instead on UK?
Why does Apple Operating Europe (Cork, Ireland, 100% owned by Apple Inc. but not operated in the US) has to pay them?
I really understand and adhere to the basic idea you are trying to defend but it's just not so simple with multinationals (Apple or any other), especially if the regulatory system leaves enough holes for them to make structures like this.