And I know of a few ponzi schemes that are technically within the rules. There are reasons laws exist. Follow them and soothe your misplaced guilt by spending your money on good causes. That's what Elon and Gates are doing. I don't see a problem with this line of thinking.
I know we're speaking broadly here and there's a lot of nuance to what constitutes right or wrong, but I think its pretty reasonable to say that if you're gaining money from being unethical, you are part of the problem - that's the issue.