CVS Health (CVS 1.57%) and Walgreens Boots Alliance (WBA 5.44%) are two top names in healthcare. CVS is larger and more diverse than its rival, which focuses on pharmacy retail. But soon, the two could be on a collision course again as they both expand into primary care.

However, over the past year, their share prices have been diverging, with CVS stock rallying 21% while shares of Walgreens have plummeted by 27%. Will this trend continue, and are investors better off going with CVS, or can Walgreens rally from its lower price point?

The case for CVS

CVS makes sense as an investment for risk-averse investors looking for diversification and overall stability. In the past 12 months, CVS' revenue totaled just under $308 billion. Walgreens generates less than half of that, reporting roughly $135 billion over its last four quarters.

CVS' business is broader than just pharmacy retail and also includes a pharmacy benefits management business, a health insurance company, and potentially a home health business as well, as it recently announced plans to acquire Signify Health. On a recent earnings call, the company also hinted at a big move, planning to get into primary care, also potentially through an acquisition. 

Already a top healthcare company, CVS is planning to get even bigger and stronger. And it has the resources to do so, generating free cash flow of nearly $16 billion in just the past year. That gives the company ample room to take on acquisitions while still paying dividends (which cost the company less than $3 billion annually).

Currently, the stock's dividend yield is 2.2%, which can make CVS an even better buy for long-term investors who just want to buy and forget about it while collecting some recurring income as the business grows.

The case for Walgreens

Walgreens is an underdog when compared to CVS. But as an underdog, it also has more potential to surprise investors and, thus, lead to bigger gains. At around $36 a share, Walgreens stock is trading at a depressed price-to-earnings multiple of just 6. CVS, by comparison, trades at a multiple of nearly 17. 

Although its cheap valuation and struggling stock price might suggest Walgreens is a value trap, the stock does offer investors some promising potential. After all, this is still a business that has generated $3.4 billion in free cash flow over its last four quarters -- more than double what it has paid out in dividends ($1.7 billion).

Cash is king, and it provides the company with the resources it needs to take on new initiatives and capitalize on new opportunities. One such example is the company's $5.2 billion investment into primary care company VillageMD last year. Through that deal, Walgreens plans to open 1,000 primary care locations at its stores by 2027. 

It can be a risky strategy, but what makes sense about it is that it is a logical extension of its pharmacy retail business. Consumers already visit their neighborhood Walgreens for prescriptions, booster shots, and day-to-day groceries. Making primary care available nearby will only complement its business and give consumers more reason to make a more regular trip to its stores if they know they can also check off a trip to the doctor's office at the same time.

While CVS has gotten much bigger than Walgreens, there can be a danger of diversifying too much and getting away from your core competencies and strengths. For value-oriented investors who are willing to bet on the underdog, Walgreens makes for an attractive contrarian investment. Its fundamentals still look strong, and this is also a top dividend stock that pays a yield of 5.2% -- three times what the S&P 500 averages (1.7%).

Why I'd buy Walgreens instead of CVS

Walgreens' growth days aren't over, even though some investors may be unconvinced of that right now. With a much lower valuation than CVS and a top dividend yield to go along with some exciting growth opportunities, Walgreens is the healthcare stock I'd go with today. But for risk-averse investors, CVS could be the better option.