Indeed, our governments should put a stop to it. But do you think it's moral?

No more, or less, immoral than it would be for Amazon to deny their shareholders dividends by paying taxes they aren't required to.

And corporations, especially publicly traded corporations, are required by law to protect their shareholders' interests, after all. It would be arguably illegal for them to not take full advantage of any tax loopholes they come across.