Many investors learned a hard lesson this year. The stock market can lose a lot of value very quickly. Historically low interest rates, stimulus checks, and geopolitical conflict conspired to send the inflation rate to a 40-year high, setting in motion a market crash that erased $9 trillion in wealth through the first half of 2022.

In fact, after slipping into a bear market on Jan. 3, 2022, the S&P 500 delivered its worst first-half performance since 1970, and the broad-based index declined for three consecutive quarters. Unfortunately, it is impossible to know when the bear market will end. But investors can take solace in two facts.

First, the S&P 500 has survived more than a dozen bear markets over the last century, and each one ended in a new bull market, meaning the index eventually recouped its losses and went on to hit new highs. Second, bear markets have historically been excellent times to invest. Half of the S&P 500 index's best days in last two decades took place in bear markets, and another 34% took place in first two months of a new bull market (before it was clear that the previous bear market had ended), according to Hartford Funds.

For that reason, now is a great time to buy an S&P 500 index fund.

Advice from Warren Buffett: Buy America

In October 2008, the stock market was crumbling under the strain of the Great Recession when Warren Buffett wrote a now famous op-ed piece for The New York Times. I highly recommend reading the article in its entirety, as Buffett displays a remarkable ability to remain levelheaded during a devastating financial environment. But the four-word headline alone is packed with valuable insight for investors: "Buy America. I am."

The S&P 500 index is a barometer for the American economy. It tracks 500 of the largest U.S. companies across all 11 stock market sectors, and it represents an even blend of value stocks and growth stocks. That means buying an S&P 500 index fund is like buying a slice of America, and it should come as no surprise that Buffett has regularly recommended that strategy, especially in down a market. Circling back to the 2008 op-ed piece, Buffett explained that investors should relish bad news because "it lets you buy a slice of America's future at a marked-down price."

Which S&P 500 index fund is the best?

Investors looking for an S&P 500 index fund have many good options. Warren Buffett actually owns two through Berkshire Hathaway's investment portfolio. The first is the SPDR S&P 500 ETF (SPY -0.21%), which is managed by State Street Global Advisors, and the second is the Vanguard S&P 500 ETF (VOO -0.23%), which is managed by The Vanguard Group. The former bears an expense ratio of 0.0945%, meaning investors would pay $9.45 per year on a $10,000 portfolio. The latter bears an expense ratio of 0.03%, meaning investors would pay $3 per year on $10,000 portfolio.

Apart from that difference, the SPDR S&P 500 ETF and the Vanguard S&P 500 ETF are essentially identical, and either one is a good choice.

In a nutshell, patient investors can buy an S&P 500 index fund with confidence in a bear market because the S&P 500 has recovered from every past downturn, and there is no reason to believe the current downturn is any different. That said, the S&P 500 may fall further in the coming months (or years), so investors should be prepared to hold through volatility.