I personally do not see that Apple did wrong. They got a good deal and leveraged it. If the EU deems what Ireland offered to be illegal, I guess they can void the deal. However, doing so retroactively would be wrong. It should only be going forward. Apple can then decide what to do for tax shelters moving forward, but paying back taxes seems to penalize Apple for the "illegal deal" made by Ireland.
EU regulations exist in order to ensure a level marketplace. If Apple receives illegal state aid, it skews the competitive landscape. This is wrong for a multitude of reasons.
There is no retroactive law being applied here. If you receive illegal state aid, it may - under law which was applicable at the time - be recovered. In this case, it is limited to 10 years, or from 12 June 2003. Apple may have to pay this back:
The Commission wishes to remind Ireland that Article 108(3) of the Treaty on the Functioning of the European Union has suspensory effect, and would draw your attention to Article 14 of Council Regulation (EC) No 659/199935, which provides that all unlawful aid may be recovered from the recipient.
I would recommend that you read the letter from the commision as well as the applicable regulations.