When did playing 'smart' start to mean that you were a cheater?
At its core, our democratic process and legal system were designed to take care of issues like these over time.
Meanwhile, other countries certainly are incented to find a way to make to entice big players to play on their turf ... and creating a tax haven is one way to do it.
Going back to Apple, on one hand I'm sure the government wishes they had paid more taxes, but on the other hand I'm sure they are glad that Apple didn't move away and take their tax dollars with them.
As you have probably surmised, this happens on many levels and in many places.
In trading, for example, statistical arbitrage was once an easy way to make money (if you knew how to do it). The reason was that relatively few people knew how to do it, so there was limited competition (and fairly easy winnings). Then, as the success of the early winners signaled others into the game, it got harder to win. People started programming computers to find mis-priced assets and the discrepancies filled themselves in moments. As you might guess, many traders who have tried statistical arbitrage have moved on to other things.
Identifying inefficiencies (or loopholes) in a system is potentially good for everyone involved. It benefits the person who identifies the inefficiency, because they get paid. Yet, it is also good for the system because it identifies weaknesses or areas that need additional attention, oversight, or regulation. And it provides a feedback loop allowing the parties to course-correct and play smarter. Over time, this often results in real progress.