Indeed, hence the meme "stocks only go up". There's a grain of truth to the meme, though. The safest bet I can think of to make is that, on average, the S&P 500 will be higher in the future than today. Obviously there are temporary down trends but on a time horizon of years to decades I can't think of a safer bet.
It’s a bet on the continued existence, and willingness/ability to honor its obligations, of the US federal government.
If that bets goes bad, the typical investor in Treasuries has perhaps bigger problems to worry about, but it’s still a bet IMO (and one which will inevitably eventually go bad).