The past year hasn't been easy for most people, and if you have money invested in the stock market, you've probably watched your portfolio sink to some degree.

It can be tempting, then, to stop investing altogether until the market stabilizes -- especially as a recession is looking more likely. But is that really the right move? Or is it safe to keep investing? Here's what history says.

Bear and bull figurines with world map in the background.

Image source: Getty Images.

More volatility could be coming

Nobody knows for certain what the future holds for the stock market, but more experts are betting on a recession.

While the U.S. continues to add jobs and the unemployment rate has remained low, inflation is still high. The Federal Reserve has already raised interest rates multiple times over the past few months in an attempt to rein in inflation, but that doesn't seem to be having a strong enough effect so far.

If inflation doesn't slow down significantly in the coming months, the Fed could take a more aggressive approach to rate increases -- potentially inducing a recession. Although the stock market and the economy are separate entities, stock prices could tumble even further if we face a steep economic downturn.

What does this mean for your investments?

The future could be shaky for the market, but there's fantastic news for long-term investors: This volatility shouldn't affect your goals.

Short-term ups and downs are tough to stomach. However, the market's long-term track record when it comes to recovering from downturns is impeccable. As long as you stay invested for the long haul, it's actually harder to lose money in the market than it is to make money.

Analytics firm Crestmont Research studied the S&P 500's rolling 20-year total returns since 1900, and researchers found that all the years examined (from 1919 to 2022) produced positive total returns.

This means that if you had invested in an S&P 500 index fund at any point after 1900 and simply held that investment for 20 years, regardless of any volatility in that time period, you'd have earned positive returns.

^SPX Chart

^SPX data by YCharts

Even over the past two decades, the market has faced some exceptionally harsh downturns -- from the dot-com bubble burst to the Great Recession to the crash in the early stages of the COVID-19 pandemic.

However, despite all of those slumps (including the current one), the S&P 500 is still up by more than 166% since 2000. In other words, if you had invested in an S&P 500 index fund and simply held your investments, you'd have more than doubled your money by today.

One important caveat

Over the long term, the market is incredibly safe. But it's still up to you to choose the right investments. If you're investing in unsafe stocks, your portfolio may not survive a downturn -- even if the market as a whole thrives.

The best stocks are the ones from companies with solid underlying business fundamentals, which includes everything from healthy finances to a competitive advantage in the industry to a knowledgeable leadership team.

The stronger the company, the more likely it is to succeed over time despite short-term volatility. And the more of these stocks you have in your portfolio, the better your chances of pulling through this downturn -- no matter what's on the horizon.

It's not an easy time to be an investor, but things will get better. Even if we do face a recession at some point, investing in the stock market remains one of the most effective (and safest)  ways to build long-term wealth.