The last 300 years of civilization have been amazingly atypical.
We have experienced industrial revolution after industrial revolution. Economic revolutions that would have changed the world in 1000 AD show up as noise. Coal, Canal, Rail, Trade, Electricity, Refrigeration, Oil, Gas, Nuclear, Assembly Line, Vacuum Tube, Mass Education, Transistor, Integrated Circuit, Nano-tech, Antibiotics, Slaying of absolute Poverty, Democratic, Feminism, Superhighway, Automobile, Airplane, and on and on and on.
A cascade of miracles and world-shaking events that have intertwined and together generated a many century long economic singularity that has upended the entire world and generated today's world.
The question you should ask, is tomorrow going to be like today? And the answer is yes; in weather, and in economics, the most likely bet bet is always "things keep on going like they have in the short term". But next week? Next month? That is often not much like today.
There is reason to believe that the yield on the above revolutions will continue to propel the economy forward, and that there are multiple promising new revolutions on the horizon.
But barring that kind of world-shaking revolution, you are not going to maintain a 5% real return on investment over another centuries for the stock market. The value of investments has to go up by a factor of over 100 in order for that to happen, and the US stock market is already close to 20 trillion dollars.
For it to have a market cap of 2 quadrillion dollars the world economy will have to be much larger than it is today. And to be that much larger, the world would have to be a much stranger place that values very different things.
We are currently roughly a K-type 0.72 civilization. A simple linear expansion of our power of 100x brings us up to K-type 0.92, which is going to cook the planet from waste heat (not from CO2, but just from the waste heat of the energy it uses!)
Efficiency can mitigate this, but only to a degree. 100x more efficient technology is going to less believable than a beanstalk and space colonies.
If you believe that the stock market is going to continue to grow at 5%/year for the next century, start investing in really out-there technologies. Gene editing, virtual and augmented reality, space beanstalks and private lift, miraculously cheap energy storage, etc. Because simply refining the technology of today won't get us there.
Modern industrial civilization has been a miracle factory. That is what pulled off that growth rate. If the miracles stop coming, so does the growth.
There is a road to it. It would involve clean energy, mass personal automation and friendly (not smarter than human) AI, and the entire world lifted up to the standard of living of the top 3% of the USA on average. But it is far from guaranteed.