First, in a retirement plan you do not pay tax each year on the investment gains. You only pay tax once: either before contributing the money to a Roth plan, or when withdrawing from a traditional retirement plan.
Suppose you have 5% gains for 40 years, and a 15% tax rate.
If tax is applied every year, your annual return is reduced to 4.25%, and you end up with 1.0425^40 = 5.28 times your initial investment.
With deferred taxation, you end up with (1.05)^40 x 0.85 = 5.98 times your initial investment.
Secondly, tax rates are not constant. The US income tax is progressive, meaning that higher incomes are taxed at a higher rate. Delaying some of your income into your retirement years spreads it more evenly and results in a lower average tax rate.
If you earn $60,000 one year and $0 another year, your total tax is $8,139.
If you earn $50,000 one year and $10,000 another year, your total tax is $5,639.