They follow the letter of the law. If the law is bad, change the law, don't bash Google for managing it's tax liability cost effectively and accuse them of being evil.
"Don't be evil" and "Don't break laws" are very different things. If Google's motto was just "don't break laws", they wouldn't be inviting quite so much criticism for legal-but-dubiously-ethical stuff like this.