Interestingly, the decision, as I understand it, was based on treaty provisions that outlaw state aid to corporations that disrupts or distorts competition, not a tax provision. The EU essentially said the favorable tax treatment was an illegal form of state aid; and thus retroactively made changes to Ireland's tax laws.
No matter how you feel about the Apple case, retroactively changing tax laws is, IMHO, bad policy since no company can be assured that any tax treatment it got won't be changed and the change made retroactive, resulting in a large tax bill in the form of a fine. The company was complying with the laws as written and the tax authorities agreed they were compliant, and then all of a sudden you are not.
Because they had negotiated such a deal in order to harvest money from other countries. That's the illegal part.
In addition to your point, which is right on the money, the decision was ludicrous on its face - a non-resident company owes taxes to a country on sales made outside of that country? Crazy.
Yes, it's because it's a Union