It is not illegal to avoid taxes, rich people avoid taxes all the time.
Capital gain is generally lower than income tax in most countries. This is because most of the people earn their money with wages and not by selling stuff.
Therefore, the first way to avoid taxes is to earn more money buying and selling things.
If you do not sell, then you are not taxed.
Rich people avoid taxes accumulating valuable stuff (stocks, properties, art, cryptocurrencies etc…).
If the stuff you buy goes up in value, you earn unrealized gains, and therefore you do not have to pay taxes if you just hold.
The third legal way is to get loans against the valuable stuff you have. The loan terms are lower than paying taxes.
And the money you get with loans are not taxed.
Furthermore, if you are rich and the taxes are unfavorable in your country, then you can just leave.
If you are poor and you do not have much money, than you need and must to be a good citizen and pay your taxes.
Tax is like every other market if you can access it.
Is it worth paying your amount of taxes in exchange of education, justice, healthcare, protection?
How does your state compete with their tax system and their services?