At the end of the day though, I'm sure it boils down to having both instead of trying to minmax it. Being able to liquidate a portion of your investments to, say, purchase a house is probably a good idea, which you can't do if you've been putting everything you have into a retirement account.
For example - if my wife and I max out our 401k’s - that’s about 50k we are deferring taxes on. If our pre-tax household income is 300k - then that 50k would have been taxed at 24% marginal rate.
In a year of retirement - let’s say we withdrawal that 50k but now it’s doubled (probably more than that since it only takes 9 years to double at 8% annual growth via compound interest). Now we pay 12% and end up with 88k. (Technically we’d have more than that because of the 24k standard deduction - but we’ll ignore that for the sake of simplicity)
Let’s take the non-tax advantaged comparison. We’d have paid 24% up front and invested 38k. It doubles to 76k. We’d pay 0% capital gains - but even then we end up with less investment income.