Shares of PepsiCo (PEP -2.97%) gained ground Monday after the food-and-beverage giant posted better-than-expected results in its second-quarter earnings report.

During a pandemic-ridden period, Pepsi's performance slipped from a year ago but still topped the analyst mark. Organic sales, which exclude the effect of acquisitions, divestitures, and foreign currency, fell 0.3%, while revenue dipped 3.1% to $15.9 billion, but still beat estimates at $15.44 billion. On the bottom line, adjusted earnings per share fell from $1.54 to $1.32, but topped expectations at $1.25. Profits fell as COVID-19 led to additional expenses, and Pepsi's performance was challenged in beverages.

A worker stocking a Pepsi fridge

Image source: Pepsi.

CEO Ramon Laguarta said: "Despite being faced with significant challenges and complexities as a result of the COVID-19 pandemic, our businesses performed relatively well during the quarter, with a notable level of resiliency in our global snacks and foods business."

Indeed, its food segments, Frito Lay and Quaker, shone in the quarter, as consumers stocked up on those products during the pandemic. Sales at Frito Lay North America rose 7% in the quarter, while Quaker Foods North America saw revenue jump 23% and operating profits surged 55%. Laguarta noted the effect of "consumers spending more time at home, which benefits the at-home breakfast, snacking and dinner occasions."

Pepsi shares have held their own this year, essentially matching the S&P 500 despite significant challenges from the pandemic, but what's been particularly notable about the stock's performance during the pandemic is how much it's outperformed archrival Coca-Cola (KO 0.15%)

^SPX Chart

^SPX data by YCharts

Why Pepsi's winning this cola war

Pepsi may be best known for its namesake beverage as well as its other sodas, which include Mountain Dew and Sierra Mist, but Pepsi is much more than a soda maker. In fact, a majority of its sales, 55%, come from food and snacks, while beverages make up the remainder. More than half its operating profit last year came from Frito Lay North America, showing that food and snacks tend to have higher margins than beverages. That diversification has given it an advantage over Coca-Cola, which exclusively sells beverages and has historically resisted getting into food and snacks. 

First, the food and snack brands give Pepsi a ballast against health concerns and other headwinds around soda. Soda sales in the U.S. peaked in 2004, and have been on the decline in Europe and other markets in recent years. Diet soda, in particular, has been hit hard by concerns about artificial sweeteners like aspartame, and consumers have switched to alternatives like bottled water, coffee, seltzer, and coconut water, among other options. With less exposure to soda than Coke, Pepsi has weathered these challenges better than its chief competitor. Pepsi's beverages are also more weighted to non-soda categories with brands like Tropicana and Gatorade.

Second, Pepsi has less exposure to restaurants, where beverages were already at risk due to the rise of takeout and delivery from apps like Grubhub. Consumers are less likely to order a drink with a takeout or delivery order than they are when they dine in, and during the pandemic, dine-in restaurant service has been decimated. Pepsi acknowledged challenges in away-from-home channels, which include convenience stores and restaurants, but at Coca-Cola, away-from-home consumption makes up half of the company's revenue. With consumers staying at home for much of the second quarter, those sales look particularly vulnerable.

Coke will report second-quarter results on July 21, with analysts expecting revenue to fall 26%, and earnings per share to drop by a third.

Why you might want to avoid both stocks

Considering that trends against soda seem unlikely to abate and the effects of the pandemic will only present more challenges for Coca-Cola, Pepsi looks primed to continue to outperform its rival. 

However, both of these stocks have actually underperformed the S&P 500 over the last decade.

^SPX Chart

^SPX data by YCharts

Coke's and Pepsi's strengths are evident. They dominate the global beverage industry and own a number of the world's most popular food and beverage brands. However, as consumer staples companies, they operate in a slow growth industry where the market is mature or even declining for many of their products. That explains why they've underperformed the average stock on the market during a bullish decade. 

Therefore, dividend investors who are looking for a reliable income stock may want to consider one of the other Dividend Aristocrats instead. However, if you're choosing between the two beverage giants, Pepsi continues to look like the better stock.