Stock markets can be volatile and risky in the short- and even the medium-run. But as a long-run average, stock markets (in the US, at least) have provided rewarding returns. Elroy Dimson, Paul Marsh, and Mike Staunton provide some useful background in the Credit Suisse Global Investment Returns Yearbook 2020.
The "Summary Report" is freely available on-line.
Here are a couple of figures showing nominal and real rates of return on stocks, bonds, and Treasury bills for the US market from 1900-2019. (Thanks to the authors for permission to reproduce the figures shown here.) In real terms, US stock market returns have risen at a 6.5% annual rate over this time, compared to 2.0% for bonds and 0.8% annually for bills. This is the "equity premium," the name given to the pattern that if you invest in stocks for the long term--and thus ride through the hills and valleys--your patience will be rewarded after a decade or two.
This general pattern of higher stock market returns holds across many countries, but it's stronger in the US than in most others. Here's a figure showing the return on equities from 1900 to 2019 for a range of countries. Sweden's (fairly small) stock market is at the top, with the US just a bit behind. Some of the stock markets that existed in 1900, like those in China and Russia, were wiped out altogether. (Russia represented about 6% of global stock market capitalization in 1900).
The high returns for US stock market mean that over time, US stock market capitalization has become a substantially larger share of the global total. For example, the US stock market was 15% of total global stock market capitalization in 1899 (top pie graph), but was 54.5% of global stock market capitalization in 2019 (bottom pie graph).
This pattern raises some obvious questions. What specifically is it about US stock markets that has enabled them to grow so robustly over the long-term? In particular, are the key factors more closely related to events and patterns in the US economy as a whole? To characteristics of US corporations? Or to something in the US institutional/financial/legal framework which gives US shareholders a well-founded belief that their stock ownership gives them an actual claim on corporate profits that will be respected in the future? Naturally, these questions also raise concerns about whether US stock market investors with long-term horizons--like pension accounts, insurance companies, and retirement accounts held by individuals--will be able to count on higher stock market returns in the future, too.
The report by Dimson, Marsh, and Staunton has a lot of other material of interest, as well: how factor investing has worked over time; the "golden age" of US bond markets from 1982-2014; environmental, social and governance investing; and more.