Investing in the stock market can be intimidating even when the economy is strong, but investing during periods of volatility can be even more nerve-wracking.

Because investing always carries a certain amount of risk, many people shy away from it. In fact, nearly 44% of baby boomers say that right now is not the best time to invest in the stock market, according to a survey from Personal Capital.

However, retirement can be incredibly expensive, and it's tough to save as much as you need without investing. The average worker estimates retirement will cost around $1.7 million, a survey from Charles Schwab found, and unless you have loads of spare cash to set aside for retirement, it will be challenging to reach that goal by stashing your money in a savings account.

Fortunately, investing isn't as daunting as it may seem, and it's one of the best ways to build a healthy retirement fund -- even when the country is in a recession.

Older man looking at a laptop.

Image source: Getty Images.

Why investing is vital

Investing in the stock market does involve more risk than sticking your money in a savings account or stashing it under your mattress. However, the potential rewards are also much greater when you invest.

Even the best savings accounts only have interest rates of roughly 1% per year. If you were to start saving at age 25, socking away $100 per month earning 1% annual interest, you'd have close to $60,000 saved after 40 years. But if you were to invest in the stock market and earn a modest 7% annual return, you'd have accumulated nearly $240,000, all other factors remaining the same.

Of course, as we saw earlier this year, the stock market can experience wild ups and downs. These ups and downs don't always coincide with recessions, either. In fact, when the National Bureau of Economic Research announced that the U.S. was officially in a recession, the stock market was bouncing back and recovering its losses from earlier in the year. Recessions can make the market more volatile, but if you press pause on saving until the economy is in better shape, you're missing out on your most valuable resource: time.

Although there is always a chance you could see your investments take a hit during market downturns, the rewards are almost always worth the risk. And by allocating your investments properly, you can minimize your risk as much as possible.

Proper asset allocation can significantly reduce your risk

Asset allocation, in a nutshell, is how your money is divided among your investments. Younger and more risk-tolerant investors may invest heavily in stocks because, although they're riskier, they have more potential for significant gains. As you get closer to retirement, though, it's a good idea to take a more conservative approach and invest more in bonds and other "safer" investments.

By investing more conservatively, you won't see your savings grow quite as much. However, your money will also be more protected against stock market downturns when you're not investing as much in stocks.

It may be tempting to invest conservatively even if you're still decades away from retirement, but there is such a thing as being too careful. If you only invest in bonds and other conservative investments, you'll miss out on the chance to see significant gains. Bonds typically only see average rates of return of around 5% to 6% per year, while stocks have historically experienced returns of around 10% per year, on average.

If you still have years before you can even consider retiring, investing more aggressively in stocks may be wise. You could see your savings take a hit in the short term, but over time, they'll bounce back. Then, as you get older, you can gradually shift your investments to lean more conservatively, which will better protect your money from future stock market crashes.

Although it can be daunting to invest in the stock market (particularly when the future is uncertain), it's one of the best ways to save a significant amount of money for retirement. You may never be able to eliminate risk entirely when getting involved in the stock market, but by being strategic about how you invest, you can boost your long-term savings and enjoy a more financially secure retirement.