Gold doesn’t provide a dividend.
Inside a 401k dividends get reinvested, on top of that companies value income go up with inflation simply because they’re getting a similar cut of larger numbers.
That’s why long term stocks are a vastly better investment.