It's been a rough year for investors. The S&P 500 has been in a bear market for nearly three months, and that pain could continue as inflation, rising interest rates, and other macro headwinds rattle the economy. Right now, the S&P 500 is down by about 17% year to date. 

Yet, Coca-Cola (KO 0.15%) seems to have been immune to the sell-off. The beverage giant's shares are actually up by about 3.5% this year. It also still looks reasonably valued at 24 times forward earnings and pays an attractive dividend with a forward yield of 2.8% at the current share price. Should investors consider it a good, safe-haven stock in this choppy market?

A person holds a Coca-Cola plate at the Coca-Cola Store in Orlando.

Image source: Coca-Cola.

Why do defensive investors love Coca-Cola?

Coca-Cola has struggled due to declining soda consumption rates over the past few decades, but it acquired and launched more brands of bottled water, teas, fruit juices, coffee, sports drinks, and even alcoholic beverages to offset that slowdown. It also refreshed its sodas, offering smaller can and bottle sizes, sugar-free versions, and new flavors to attract customers.

Coca-Cola's organic sales rose by 6% in 2019, but declined by 9% in 2020 as restaurants shut down during the first phase of the pandemic. That revenue downturn was short-lived; its organic sales grew 8% in 2021 as the lockdowns ended, and management expects growth in the 12% to 13% range this year -- even though it has suspended sales in Russia, faces more COVID-19 lockdowns in China, and is grappling with inflationary headwinds. The beverage king expects its comparable EPS to grow by 5% to 6% this year, or 14% to 15% on a constant-currency basis. 

The company is fairly well-insulated from inflation and other macroeconomic headwinds because consumers tend to continue buying its beverages steadily even during downturns. That resilience, which is supported by its evergreen brands, gives it the ability to gradually raise its prices to keep pace with inflation.

Coca-Cola's consistent growth has enabled it to raise its dividends annually for six straight decades, earning it a spot among the elite Dividend Kings -- those few companies that have maintained their payout-boosting streaks for at least half a century. Coca-Cola only spent 73% of its free cash flow (FCF) on dividend payments over the past 12 months -- so it still has plenty of room for more hikes. It also plans to spend about $500 million on stock buybacks this year.

Why do long-term investors dislike Coca-Cola?

Coca-Cola is a good defensive stock to hold during a volatile bear market, but it has consistently underperformed the S&P 500 over the longer term. Over the past 20 years, Coca-Cola's stock rose 145% as the S&P 500 gained 339%. If we factor in reinvested dividends, Coca-Cola's total return of 338% still falls well short of the S&P 500's total return of 552%. Coca-Cola also underperformed the market over the past 10 years, delivering a total return of just 123% compared to the S&P 500's total return of 240%.

Past performance never guarantees future results, but that pattern implies that an S&P 500 index fund or ETF might be a better long-term investment than Coca-Cola. Meanwhile, over the past 20 years, its rival PepsiCo (PEP -2.97%) -- which also sells packaged foods through its Frito-Lay and Quaker Foods brands -- beat the market with a total return of 676%.

The market's recent rotation toward defensive, blue-chip stocks has also boosted Coca-Cola's price-to-earnings ratio to its highest levels in more than two years. Therefore, Coca-Cola's year-to-date rally seems to mainly have been driven by fear -- and the stock might pull back if that fear subsides.

Lastly, Coca-Cola may be repurchasing its own shares, but its insiders still sold more than twice as many shares as they bought over the past 12 months. That tepid insider interest suggests its stock might be overvalued. By comparison, PepsiCo's insiders bought slightly more shares than they sold during the same period.

Is it the right time to buy Coca-Cola's stock?

I believe Coca-Cola will remain a safe stock to buy as interest rates continue to rise. It should also remain a good dividend stock to hold in a diversified portfolio. However, investors should realize that the stock isn't cheap, and over the long term, it could underperform the S&P 500 -- which, as a broad market index, houses a wide variety of higher-growth stocks. Therefore, Coca-Cola is worth buying as a defensive play today -- but investors shouldn't expect it to generate jaw-dropping returns.