Any business is going to whatever it can to find loopholes and ways around paying taxes. I have no doubt that there was something going on there that let them get by with something. This is the problem with most of the corporations in this world. Profits are everything and all they really need is sustainability.
I do not believe that Ireland and Apple broke any laws with their financial relationship. Apple simply outsmarted the rest by cutting a deal with them. I do not see how this any different than a person hiding money in a Swiss bank account to avoid taxes. There are millions who do it everyday.
A very important caveat here: I don't think Apple broke US tax laws, but their actions should have. Unfortunately American laws are designed to lopsidedly defend corporations from the penalties that ordinary individuals would typically face. Apple did what it could to skirt paying taxes in the country it is headquartered in. That should be a crime, but isn't.
Although the EU may not support the tax incentives offered to Apple by Ireland, such incentives are legally acceptable under Irish law. The tax incentives were designed to encourage Apple expansion in Ireland. As of 2014, Apple employs some 4,000 people in Ireland. Because the incentives are designed specifically to spur further economic growth, it is difficult to construe the benefits as "state aid."