I agree, a company, like any individual, wil always choose the best option available to them. It is morally bereft but that doesn't really seem to matter in business.This is a deal Ireland has made for Apple - not Apple making a massive tax fraud. EU is interfering with the individual country tax system (to be honest I'm not in the details) which sounds a lot like many of the reasons The UK voted out.
Nobody should cheat, but this sounds like it isn't on Apple (get presented with a good deal by a country and accepting it isn't a crime) but more like the country it self
The onus however is on the Irish Government who have a long history of this kind of deal and only in recent years began to reduce them due to increasing ire drawn from other EU states.