It’s legal because he did exactly what every single business owner in the United States attempts to do: minimize tax exposure. Just because Amazon did so successfully doesn’t mean they’re criminals. They’re just smart. Why pay taxes if you don’t have to? They don’t owe you anything.