It’s an extreme example, I know, but it’s worth bearing in mind:

How can this be? A country undergoing hyperinflation and economic collapse sees its stock market explode higher?
When the value of a nation’s currency goes down due to inflation, its stock market may increase, sometimes by a lot. Say a stock is trading at $50 per share, but then the country undergoes rapid inflation and suddenly you need $100 to buy what used to only cost you $50. Well, the stock would also then go up to $100 to reflect the decreased value of the dollar.
It’s not like the underlying company (or in this case the overall index) actually doubled in value. It’s that the currency declined in value. If the price of a cheeseburger goes from $5 to $10, it’s not like the cheeseburger got twice as tasty. It’s merely the fact that $10 is the new $5 in terms of purchasing power.
Inflation eats into stock gains. If the market goes up by 5% in a year but inflation is running 10%, then real stock gains are actually -5%.
Now, of course, negative real gains of -5% in the stock market due to inflation are still preferable to sitting on cash and being -10%. Stocks are still a hedge against inflation even if inflation is outpacing the stock market. Cash has no hedge against inflation at all, so during periods of high inflation people will pile into the stock market just so they don’t have to sit on cash that is steadily losing value by the day.
According to Statista, in 2017, Venezuela’s inflation rate was 438%. So even though the stock market quadrupled that year, it still didn’t outpace inflation. By 2018, inflation was running at over 65,000% a year.
I bring all this up as a warning not to take stock prices at face value. As we head into a period of potentially high inflation here in the US, don’t forget to take inflation into account when it comes to stock prices and returns. Inflation causes stock prices to increase along with the price of everything else. It might not be the price of your stocks that is going up–it could be the value of your dollars decreasing.
I’m not saying we’re about to be in a Venezuela-like hyperinflation situation, obviously that’s an extreme scenario. I’m just trying to illustrate a point here.