CVS Health (CVS -0.22%) has been selling health and beauty products since 1963. Over those six decades, the pharmacy operator and retailer built up a giant operation that now includes a pharmacy benefits business (CVS Caremark) and a health insurance business (Aetna). With more than 300,000 employees and a ranking of fourth on the Fortune 500, CVS Health can lay claim to being the world's largest healthcare company.

But how has CVS Health's stock performed for investors? Let's take a closer look at how much a $25,000 investment in CVS would have grown over the past two decades, and whether that would have made for a better investment than simply putting your money in the S&P 500.

In 20 years, share prices of CVS Health have quadrupled

On Sept. 6, 2003, CVS' stock closed at a price of $15.60. Buying $25,000 worth of stock back then would have gotten you approximately 1,602 shares of the healthcare company. The stock now trades around $65.65 a share, so that investment would be worth roughly $104,320, for a 317% return. That looks to be some good growth over the years -- but it's also important to put it into context since it does span 20 years.

A 317% return averages out to a compounded annual growth rate of 7.4% over a 20-year period. Experienced investors know that over its long existence, the S&P 500 has an average return around 10%. And so while CVS' returns do look good at first glance, they may not be as impressive. To be fair, the broader market underperformed its broader average in recent years. During the same 20-year timeframe, the S&P's returns were close to 334%, or 7.6% annually.

When calculating total return, which includes dividends reinvested, the gap actually widens with CVS' returns of 481% lagging behind the 549% total returns the broad index generated over two decades. Using total returns, a $25,000 investment in CVS would be worth $145,300 while the same investment in the S&P 500 would be worth $162,135.

The stock has been struggling of late

CVS's returns underperformed, in part, because the past 12 months have been particularly troubling for CVS and its stock price dropped 34%. Investors aren't thrilled with its recent focus on acquisitions. They were also displeased with the $5.8 billion in costs CVS incurred last year in response to litigation over opioid prescriptions.

Also concerning is that there are signs CVS' business faces more competition. Most recently, Blue Shield of California, one of CVS Caremark's customers, said it would be moving away from the pharmacy benefits manager to help save costs. It's a sizable blow, as Blue Shield has nearly 5 million members. Among the companies that it will be using is tech giant Amazon, which is growing its presence in healthcare as it looks to disrupt the industry.

As companies such as Amazon and Walmart expand their healthcare offerings and compete with one another, that also puts pressure on CVS' businesses. Investors tend to express their concern through the stock's valuation and CVS now only trades at 8 times its expected future profits. The stock price is also near its 52-week low.

Can CVS Health turn things around?

CVS has been busy with a couple of multi-billion-dollar acquisitions, including an $8 billion purchase of home health company Signify Health and a $10.5 billion acquisition of primary care provider Oak Street Health. Both deals closed this year and should help CVS expand its products and services even further. Management says the company is going to pause on mergers and acquisitions for the time being as it works to integrate the new businesses into its operations.

One attractive opportunity it is piloting is the launch of primary care in its retail stores. CVS announced that project earlier this year, and it involved a start-up company, Carbon Health. Through its acquisition of Oak Street Health, however, it could potentially go deeper into that. Rival Walgreens Boots Alliance has already invested billions into primary care as it has been launching clinics near its stores.

CVS doesn't appear to be done growing, and while investors are down on the business today, they shouldn't count it out in the long run.

Should you invest in CVS Health?

CVS' low valuation and its attractive dividend yield of 3.7% make it an intriguing investment option today. Its stock hasn't traded this low since 2020, and it's an investment that is worth taking a chance on. While it faces some significant competition, it has also established itself as a trusted brand over the years -- which I think it should be able to use to its advantage, whether it's up against big tech or a big-box retailer like Walmart.

For long-term investors, now could be an opportune time to buy shares of this growing healthcare company.