Walgreens Boots Alliance (WBA -1.18%) has made for a disappointing investment to hold over the past five years. Down 41%, its performance is the complete opposite of that of rival pharmacy retailer CVS Health, which has delivered gains of more than 42% during that same time frame. While Walgreens does offer a high yield of 4.6%, that may be of little comfort to investors who have incurred such significant losses.

Whether the next five years will be any better for the stock will likely depend on the company's healthcare strategy. Walgreens looks to be going all-in on it, and that could lead to a significant recovery in the share price -- or to an even more disastrous decline that could even put the dividend in jeopardy.

Walgreens is spending billions on healthcare

Last year, Walgreens announced a $5.2 billion investment into VillageMD, which runs primary care practices. Together the companies plan to launch up to 1,000 co-located clinics (i.e., at the same location as a Walgreens store) by 2027. The company is off to a strong start and expects to have 200 co-located clinics by the end of this year.

VillageMD recently announced plans to acquire Summit Health-CityMD, which is a provider of primary, specialty, and urgent care. It has over 370 locations across five states. Both Walgreens and Cigna are investing money to help fund the $8.9 billion transaction. Walgreens' portion involves a $3.5 billion contribution, which will ensure that it retains a 53% controlling stake of VillageMD.

The company is expecting lots of growth by 2025

As a result of the acquisition, Walgreens is now projecting even more growth for its new U.S. healthcare segment. By 2025, it expects revenue will be between $14.5 billion and $16 billion. Previously, it forecasted no more than $12 billion in revenue.

But investors shouldn't expect much in the way of profitability, as Walgreens says that the recent deal may add no more than $0.11 in earnings per share in fiscal year 2024. In fiscal year 2022, which ended on Aug. 31, the company's U.S. healthcare segment brought in $1.8 billion in sales and incurred an operating loss of $829 million.

Why this could be a risky strategy for Walgreens

The idea of going deeper into healthcare is a move that could work for Walgreens. Rival CVS made a much larger investment when it acquired health insurer Aetna for $69 billion in 2018, and as noted by the stock's stronger returns in recent years, it has helped win over investors and add stability to the business.

In this case, however, Walgreens isn't just acquiring a massive company and adding it into the fold. VillageMD is considerably smaller, and this is happening as Amazon and Walmart are also showing more of an interest in primary care -- and could be potential rivals of Walgreens' in the future. Amazon announced plans earlier this year to acquire 1Life Healthcare, better known as One Medical, and Walmart has been slowly launching its own health clinics in recent years.

What's more, Walgreens doesn't have the strong financials either of those businesses has. Walgreens has generated $2.2 billion in free cash flow over the trailing 12 months, which is sufficient to cover its dividend payments totaling $1.7 billion during that stretch, but not a whole lot of room for much else.

This is where I see a potential risk to Walgreens' dividend should the healthcare venture not be as successful as the business may have been hoping for. While stopping its regular dividend increases would be a seismic move for the Dividend Aristocrat, it's a risk that investors have to consider. 

Should you invest in Walgreens stock?

Walgreens investing billions more into a healthcare segment that could take years before it contributes a meaningful profit to the bottom line is risky. But at the same time, the company arguably needs to do something, as up until now there has been little reason for investors to own the stock. Between its low margins and growth that in recent years was mainly due to an uptick in vaccinations, it would otherwise be difficult to see where the company's future growth will come from.

I'm optimistic the strategy could pay off given Walgreens' reputation for being a trusted neighborhood pharmacy, and that could give it an advantage over other competitors. While I think it could be successful and Walgreens has the potential to be an underrated buy for 2023, this may not be a suitable stock for risk-averse investors to buy.