Every comment that says "this'd be fine if Ireland let every company do it"? Guess what, Ireland lets any company do it. No signup required. It's just how corporate income tax law works in Ireland.
I agree that tax havens are bad for civilization, and it seems to me that the EU's ruling is in a generally pro-civilization direction (whether or not it is, in fact, legal, under current EU law).
Also, when people say "why is the EU allowed to rule on this", the answer to such questions is always "because the member state (in this case Ireland) first agreed to a treaty, and then ratified that treaty by creating an Irish law saying that Ireland had to obey the rulings". That's how treaties work. I'm not saying that's a good thing (I have serious concerns about the interaction between international treaty processes and what's left of democracy, but repairing it isn't helped by misunderstanding the mechanism). Again, the EU high court has jurisdiction because Irish law says it does, backed up by the probability that if Ireland flouts it hard enough, long enough, other member states are likely to jointly retaliate.