Coca-Cola (KO 1.22%) is a popular Warren Buffett stock that has an excellent track record for dividend growth and overall profitability. The soft drink company has a wide moat as its products are known around the world and its logo is iconic.

But despite all these positives, it hasn't made for a great investment over the years, highlighted by one astounding stat. Let's see what that is.

Coke's beaten the S&P 500 in only three of the past 10 years

It may be surprising for investors to learn that despite having such a strong business, Coca-Cola hasn't made for a good investment over the past decade. Here's how the beverage stock has performed versus the S&P 500:

Data source: Company filings. Chart by author.

What's notable in the chart above is that over the past decade, Coca-Cola stock has outperformed the S&P only in years when the index's returns were negative. This suggests that while Coca-Cola can be a good defensive stock to own in bad times (perhaps as investors flock to it for safety), it may not be worthwhile over the long run, when the markets are performing well.

Even factoring in the dividend, the S&P 500 was better

One of the benefits of owning Coca-Cola stock is that it pays a good dividend, which currently yields around 2.9%. And it's also a Dividend King, with a track record for raising its payouts for 61 straight years.

That means the longer you hold onto the stock, the higher the dividend income you'll likely receive from the soft drink giant. Although the stock's payout ratio is around 80% and not terribly low, there's still room for the company to make more increases to its dividend in the future given its strong financials.

However, even when you include Coca-Cola's impressive dividend, your gains would have still been much better going with the index over the past decade. Here's how a $10,000 investment in the stock would have compared with the S&P 500, when including dividends:

^SPX Chart

^SPX data by YCharts

Will 2023 be a good year for Coca-Cola stock?

Thus far in 2023, Coca-Cola's stock is down 3% and it has been underperforming the S&P, which is up 9%. The case for Coca-Cola being a good stock this year is as a safe play, in case inflation continues to be a problem and if a recession ends up taking place, potentially crippling growth stocks in the process.

Coca-Cola's business has been resilient amid these challenging economic conditions with the company reporting $11 billion in revenue for the first three months of 2023 and the top line rising 5% year over year, even as the company has increased the price of its products. Unit case volumes still rose by 3%.

What makes this is a relatively safe business to invest in is that in addition to consistent demand, Coca-Cola can be counted on to generate a strong profit margin:

KO Profit Margin (Quarterly) Chart

KO Profit Margin (Quarterly) data by YCharts

This year could be a good one to own Coca-Cola stock if the markets struggle, as investors have shown a tendency to go to this blue-chip stock for safety.

However, in the long run, this may not be an ideal place to invest as there are other growth stocks out there that may have more potential. But if you're a risk-averse investor, want a safe place to hold your cash, and are willing to sacrifice some returns in exchange for stability, Coca-Cola can be a good option for your portfolio.