The EU did not suddenly discover what Irish tax laws were. They were legislated in an open process and were public records and were trumpeted loudly by the Irish government to attract investment. This state of affairs existed for decades. The EU simply wants to get its grubby little hands on Apple's money so they can use it for more dole-outs to friends of the bureaucrats and also use this as a precedent so they can expand their powers into areas where their power has been explicitly curtailed by treaty.
Apple made a business decision to invest in the EU based in part on the tax rates at the time which went into it's calculations of expected rate of return. Of course they probably did much better than what they expected, but many who made similar decisions lost money too. If tax laws are subject to change retroactively, investors have to start taking uncertainty about the tax rate and the expected rate of return into account and will demand a (potentially much) higher rate of return to invest. This is why it's so hard to attract investment in countries without stable governments and a strong rule of law even though the purported rate of return is much higher. If this continues it will lead to further slowdown in the EU economy. The current slowdown is not apparent to EU citizens only because the market is not charging the EU a credit risk premium on EU bonds and so EU governments are still able to fund public benefits by borrowing. This is something that will change quickly and lead to a Greece like situation if the EU starts acting in this manner.
As an outside observer, I did not think Brexit was a great idea but this event frankly is a very good argument for why more countries should consider EUExit and/or the national governments need to figure out how to defang the EU. The EU was supposed to be about free movement, no "TARIFFS" as in impediments to TRADE within the block and a single currency. What it seems to have turned into is unelected bureaucrats in Europe dictating to elected national governments what their tax policy must be.