Because even with crises, over the long term the only direction is up.
Its probably not so much that people trust it but either you invest broadly (index funds) and trust long historical data that the likely direction is up or you think you have more information than other people and can beat the market.
Only if you look at American stock market data. And that's extreme cherry-picking, because the American stock market is by far the best performing over the last century. What are the chances the American stock market will be the best performing next century?
The standard claim is that "even if you bought at the absolute worst time, if you held for 10 years you would have been positive after inflation". This statement is true for the US stock market, but not true for many other stock markets.
There's "lost decade" periods in the US market as well, that's why you shouldn't invest in a single market, and should apply unit cost averaging instead of dumping all your money at once.
In nominal terms it always goes up. In real terms, like priced in gold, DJIA is cheaper today than in 1929. (13 ounces of gold today vs. 14 ounces of gold in 1929).
But how often is that true? Gold prices doubled in the past 5 years, with 10% of that coming in the past few months, after declining for most of the 2010s.
Its probably not so much that people trust it but either you invest broadly (index funds) and trust long historical data that the likely direction is up or you think you have more information than other people and can beat the market.