401k reduces your taxable income when depositing money, this is more tax efficient than paying normal income taxes and then also paying capital gains.

401k lets you rebalance a portfolio with zero tax implications.

The downsides are generally high fees and a 10% penalty for early withdrawal which makes them surprisingly bad for young people. They tend to start in lower tax brackets, have fewer reserves when unemployed, and face fewer risks from an unbalanced portfolio.

Pay down debt then Roth IRA when young 401k after 40 is often better than defaulting to a 401k, but saving anything tends to be more important than such optimizations.

I am alone in my peer group for doing something like this.

Cars, student debt, credit card debt all gone. (And I dread needing a new car). Covered downpayment on my house and cash for a nice shed that matches the house and a fence so my kid can play in the back yard with no issue.

Invested low 5 figures into myself taking a year off and now I am getting serious about the 401k at 41. And I am ok with that.

I never worked at a big tech company and I covered my mom's down payment and appliances and new carpet and part of her move for her to move close to me. Dad died when I was 11 so I am all she has and she was a public school teacher so she's on a small pension.

We all walk a different life and I know people that make my entire life savings in a year but I will eventually grow a retirement to get me through 10-15 years and then it will be what it will be. (Maybe a tank of helium and bag)