Tax evasion is lying in order to reduce your tax burden. Tax avoidance is following the letter but not spirit of tax laws. The lawyers behind those schemes claim they're legal, but it's important to remember that tax authorities often close schemes and claw back the avoided tax. UK tax authorities tend to avoid going to court if possible so a lot of tax avoidance actually probably is illegal, it just hasn't been tested in the courts.
It's not just legal, it is a fiduciary responsibility of the management of a publicly traded company to minimize its tax burden. To not do so is negligent.
If they feel that they can maximize shareholder value by headquartering in a high tax location then they do so. Part of that may include fostering an image of social responsibility and vision.
On the other hand, if they feel that the company should pay more taxes than required just because, then instead of negligently continuing to operate in an unfavorable tax environment they should bring it before the shareholders and if they support it set up a foundation or charity to do so. Make it explicit that they are paying more than required to the US government because 'merica.