"Their accounting and tax may be legal"
Or maybe not. The EU commission found that the Ireland headquarter was a fictitious entity, set up purely to avoid taxes. In many countries, it is illegal to do such a thing. Consider what might happen to you when you just make up stuff in your tax return declaration to avoid paying your share.
I believe that Apple might be in quite some trouble once the national tax authorities in the rest of the world wake up. Good thing they got some money in the bank to get this sorted out :).