Hindsight is perfect in investing, since you know exactly what happened and can cherry-pick the best time to buy and sell stocks. And while you have to be careful about backtesting investment approaches because of this, a knowledge of history can provide some guidance for the future. Which is why there's a valuable takeaway from looking at how much money investors would have today if they bought energy giant ExxonMobil (XOM -0.57%) in March 2020.

Some quick numbers

In March 2020, the world was quickly coming to grips with the fact that the coronavirus was becoming a global pandemic. Fear and uncertainty were at extreme highs. Global economies were shutting down in an effort to slow the spread of the then-novel illness. The market was falling. 

A person in protective gear with oil wells in the background.

Image source: Getty Images.

One area that was getting hit particularly hard was energy. As countries shut down their economic activity, demand for energy waned. Oil prices fell and the results of companies like Exxon were set to feel a severe pullback. To show just how tough it was, Exxon earned $2.25 per share in 2019 and lost $0.33 per share in 2020. In hindsight, investors were clearly right to be worried as key world economies fell into recessions.

However, the energy industry has always been highly cyclical. If you bought early on during the downturn, such as on March 1, 2020, a $1,000 investment in Exxon would be worth around $1,650 today, not including the dividends you would have collected along the way. The yield on March 1, 2020 was around 6.5%, so that's not an inconsequential addition. By comparison, an investment in an S&P 500 index fund at the same point would be worth around $1,440 today. The yield on the S&P on March 1, 2020 was around 1.9%.

To be fair, things got worse before they got better, so this wasn't the "best" time to buy, considering that Exxon's dividend yield actually spiked over 10% at one point. And since yield and price move in opposite directions, that means the stock fell even lower than where it was on March 1, 2020. Still, the upshot here is that it looks like it would have been better to buy deeply out-of-favor Exxon during the worst of the pandemic downturn than to buy the S&P 500 index. 

The real lesson

It would have taken massive fortitude to buy any energy stock in 2020, given the global backdrop. And, as noted already, the dates here are cherry-picked to some degree. But the takeaway is still important for long-term investors. First, the energy sector is cyclical and always has been. When the economy is strong, oil and natural gas prices are usually pretty strong, and often even high. That flows through to the top and bottom lines of a company like Exxon. When the economy is weak, the opposite is true. This isn't a perfect correlation, of course, but the ups and down in the oil business are a normal state of affairs. And that means that when energy stocks are out of favor it can be a good time to buy, even if the world economy is in a tenuous state.

The next big thing to keep in mind with Exxon is that it is an industry-leading name with a strong financial position. So, if you were inclined to take a risk while the energy sector was out of favor, Exxon would be one of the safest ways to do so. Notably, its debt-to-equity ratio has long been among the lowest in the integrated energy peer group. That gives it extra financial leeway when dealing with hard times. 

Now add in Exxon's integrated model, which spans from the upstream (drilling) to the downstream (chemicals and refining) segments of the industry. That's not unique, as other integrated majors take the same approach, but it does help to soften the blow of commodity price volatility. Basically, downstream operations usually benefit when oil prices are low, so results tend to improve in that segment even though results are weak in the drilling arena. When you layer Exxon's financial strength on top of that fact, you start to see that it stands out from the pack for safety. 

Not perfect, but don't miss the point

Is Exxon the best oil investment you can possibly make? Maybe, maybe not. Peer Chevron, for example, shares a lot of similarities and is actually in a better position industry-wise right now. The real goal of this exercise is to highlight that energy stocks, like Exxon -- which is one of the most recognized energy names on the planet -- are often cheapest when things look the worst. And that's when astute investors will consider stepping into the industry's strongest names. Buying when everyone else is jumping aboard (like today), well, that's easier to do but may not be quite as profitable.