Over the past few years, COVID-19 stocks and meme stocks have at times been incredibly popular with retail investors. And while jumping on the latest bandwagon has resulted in incredible gains for some investors, others have been left holding the bag.

Today, with oil prices hitting highs not seen in more than a decade, investors have been piling money into oil and gas stocks. The cycle has become all too familiar by now, and it's a dangerous one that, again, could leave some investors incurring significant losses in the future.

A family meeting with an advisor.

Image source: Getty Images.

Oil and gas stocks are soaring -- but for how long?

Top oil and gas stocks ExxonMobil and Chevron are up 42% and 33% this year, respectively. Those are impressive gains when you consider that the S&P 500 has fallen a steep 12% over the same period. And while the companies will certainly benefit from a spike in the price of oil, it's anyone's guess how long the commodity will stay this high.

Investors shouldn't forget that it was nearly two years ago that, for the first time ever, oil prices went negative due to a significant decline in demand (as a result of the pandemic). While that may not happen again anytime soon, the prospect of sky-high oil prices continuing is just as unlikely. Demand is slowly moving away from gas-guzzling cars and more toward greener options. Electric vehicle sales topped 6.6 million last year, which was more than double the 3 million that were sold a year earlier. They now make up around 9% of the entire global car market -- as recently as 2016, that percentage was slightly under 1%.

Due to the challenges the industry has faced, including oversupply and the prospects of declining demand, oil and gas hasn't typically been where you'd find great returns. In the years 2017 through to 2021, shares of Exxon were down 32%. And while Chevron did better, its stock was flat during that time. Investing in the S&P 500, meanwhile, would have more than doubled your money with returns of 113% during that five-year stretch. Oil and gas stocks can be good investments to hold to help diversify your portfolio and perhaps even attain some attractive dividend income, but they can also be volatile and unpredictable.

A safer option is to focus on a more stable industry

If a stock you invest in depends in large part on commodity prices, then that could put your portfolio at risk. Generally, the less exposed a business is to commodities, the safer it will be over the long term. A decline in oil prices could quickly make oil and gas much less attractive. And that's why while these types of stocks are hot buys today, that may not be the case a year from now. Like meme stock AMC Entertainment that was all the hype a year ago and that has crashed 49% so far in 2022, there could be a big correction coming for today's high-flying oil and gas stocks.

An example of a much safer place to invest is the healthcare industry. Drugmaker Eli Lilly (LLY 1.96%), for instance, has continually grown in value over the years, regardless of what has been going on with commodities. During the period of 2017 to 2021, its value rose by 276%. And even year to date, it is down a modest 3%. The company's ability to adapt and develop new products has helped the business maintain operating margins of 25% or better in each of the past four years. By comparison, ExxonMobil's operating income has typically been less than 9%, and during 2020 it went negative.

One of the more promising products in Eli Lilly's pipeline is donanemab, which treats Alzheimer's and could provide the company with up to $10 billion in revenue at its peak. That is the type of long-term potential that investors should be focusing on rather than chasing the latest hot trend in the markets. And even if you aren't sure which specific stock to invest in, a safe approach can be to invest in growth-oriented ETFs that can give you a good mix of stocks for even more stable gains.