After a dismal performance in 2017, Walgreens Boots Alliance (NASDAQ:WBA) is on its way to delivering solid gains for shareholders this year. You wouldn't have expected such good news halfway through 2018 when Walgreens stock was down 17% year to date.

But the stock became too much of a bargain for investors to pass up. And it didn't hurt that Walgreens announced solid fourth-quarter results in October. But is Walgreens Boots Alliance a buy now?

Walgreens store with cars parked in front

Image source: Walgreens Boots Alliance. 

Reasons to buy

Let's start by looking at why investors should like Walgreens. One key reason to do so is valuation. Even though Walgreens stock has generated a nice gain so far in 2018, the pharmacy giant's shares still trade at only 11.6 times expected earnings. 

Another reason to view the stock favorably is its dividend. Walgreens has increased its dividend for 43 consecutive years, landing a spot in the elite group of stocks known as Dividend Aristocrats. The dividend currently yields 2.2%.

Walgreens' integration of 2,186 stores acquired from Rite Aid is going well. The company expects that synergies and store optimization will generate a total benefit of more than $650 million per year. 

The retail pharmacy world is changing. But Walgreens is changing as well. The company has expanded its online presence, with 22.5% of retail refill prescriptions in the fourth quarter initiated via digital channels. Walgreens recently teamed up with FedEx to launch a next-day drug-delivery service. 

The company is branching out in other ways, too. Walgreens and Kroger are collaborating to allow Kroger customers to shop for groceries online and pick them up at a nearby Walgreens store. The company is working with LabCorp to open more LabCorp patient-service centers in Walgreens stores. 

Walgreens is also targeting expansion in China. It launched a Boots flagship store on Alibaba's Tmall Global retail platform that gives Chinese customers access to popular Boots beauty brands. And Walgreens bought a 40% stake in Sinopharm Holding GuoDa Drugstores, a top retail pharmacy chain in China.

Reasons to avoid

Probably the main reason for investors to be skeptical about Walgreens is that everything the company is doing might not be enough to retain its market share. (NASDAQ:AMZN) appears to be on course to make a splash in the retail pharmacy industry. The e-commerce giant acquired online pharmacy business PillPack earlier this year.

Walgreens Boots Alliance CEO Stefano Pessina appeared to be dismissive about the threat from Amazon in July. When asked about the potential challenge, Pessina replied, "We are not particularly worried." This response was worrisome, however, to investors who know what has happened in the past to industries that Amazon targeted.

While Walgreens launched its next-day drug-delivery service, it did so only after archrival CVS Health (NYSE:CVS) beat it to the punch. And CVS Health could shake up things for the industry even more with its acquisition of large health insurer Aetna.

On top of all of this, there's no guarantee that Walgreens' pilot programs will be successful. As a case in point, fellow Motley Fool contributor Rich Duprey referred to the Kroger alliance as a "weird deal" that "seems to have a high probability of failure."

Making the call

If we could be assured that changes in the retail pharmacy industry won't disrupt Walgreens, the stock would probably be a screaming buy. Walgreens' valuation looks attractive. So does its dividend. 

The problem, though, is that there's no way to be sure that Walgreens won't be rocked to some extent by the changing dynamics in retail pharmacy. Some doubt whether Amazon will be successful in a highly regulated market like retail pharmacy. I don't. Amazon has enough money to buy all the expertise it needs.

I'm less certain how much CVS Health's Aetna acquisition will disrupt the industry. However, there's a reasonable chance that the combined entity could offer new products and services that put Walgreens in a defensive posture.

Could Walgreens be a winner over the next five years or 10 years? Absolutely. But in my view there are too many variables that could easily cause the stock to be a loser. Perhaps I'm just being a nervous Nellie, but I think there are other stocks with better growth prospects and less uncertainty than Walgreens Boots Alliance.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.