And it's not like Apple is innocent here. They've done illegal things in the past that directly hurt users [1] and it's employees and other people in the industry [2]. They have a long history of violating user trust [3].
This isn't to say they are unique in this. Most large companies deal with these sorts of things.
But Apple isn't innocent. They just happen to find an area where they can claim to take the high ground because their business model allows it.
[1] https://www.reuters.com/article/us-apple-ebooks/apple-collud... [2] https://www.cnet.com/news/apple-google-others-settle-anti-po... [3] https://en.wikipedia.org/wiki/Apple_Inc._litigation#In-app_p... [4] https://en.wikipedia.org/wiki/Apple_Inc._litigation#iPad_and... "The problem facing the plaintiffs is the current state of electronic privacy law, the issue being that there is no national privacy law that provides for compensatory damages for breach of privacy"
Tax law is the acts and statutes that bring it into existence, but it's also the case law that shapes it.
EU tax authorities tend to take a light touch approach - they'll tell you that they think you're non-compliant and how they want you to fix it. You can then tell them why they're wrong. They tend not to go to court against huge companies for anything other than blatant violations.
So, maybe the law is right, and Apple (etc etc) isn't following it correctly, but the enforcement of that law is wrong.
Meanwhile Apple effectively withholds tax from a range of countries who would probably use that to provide basic social services to those in need of them, or runs (through its contractors) factories that withhold basic human rights from staff.