The Dow Jones Industrials (DJINDICES:^DJI) had its worst performance in a decade during 2018. The average fell almost 1,400 points, or nearly 6%.

Yet even though the Dow lost ground for the first time in a long while, some of its components posted solid gains. Below, we'll take a look at Merck (NYSE:MRK), Pfizer (NYSE:PFE), and Microsoft (NASDAQ:MSFT) to see why they were the best stocks in the Dow in 2018.

MRK Chart

MRK data by YCharts.

Good times for healthcare

Merck's and Pfizer's big gains show that healthcare was a key sector for the stock market during 2018. Even though the returns from the two pharmaceutical giants weren't enough to keep the Dow from losing ground for the year, their gains of 36% and 21%, respectively, played their part in minimizing the average's overall losses.

For Merck, the big success lately has been Keytruda, a cancer drug that has demonstrated an ability to reduce risks of death when combined with chemotherapy treatments. Sales of the drug doubled during the first three quarters of 2018, and some analysts believe that Keytruda's annual revenue could clear the $10 billion mark within the next few years. Even with potential competition, Merck is optimistic that the drug's future is bright. Moreover, with other key treatments like its Januvia type 2 diabetes drug still generating plenty of sales, Merck has the cash flow to sustain a dividend yielding nearly 3% while also growing its business organically.

Person looking at a pill held in a glove, with dozens of other pills on a glass table.

Image source: Getty Images.

Meanwhile, Pfizer has seen gains stemming largely from decisions to restructure itself internally. The drug giant said in July that it expects to create three business segments, one for innovative medicines, one for established medicines, and the last for consumer healthcare products. Moreover, with Pfizer deciding within the last couple of weeks to work with rival GlaxoSmithKline to combine their consumer healthcare units into a single joint venture, it's possible that shareholders will receive shares of that business in a spinoff transaction. That would make Pfizer's stock a purer play on pharmaceuticals, which has been the higher-growth business for quite a while. A 3.4% dividend yield has also been a positive for Pfizer, especially among defensive investors looking for income to offset the risks of capital losses from their investments.

Microsoft keeps moving higher

Microsoft comes in third in this year's list of Dow stocks, but what's particularly impressive about the software giant's appearance on the list is that it also did extremely well in 2017, rising 38%. That puts this year's 19% gain into a different perspective, and the extent to which the stock has held onto its positive returns despite recent market turbulence is encouraging for shareholders.

Moreover, Microsoft has been vying for the leadership position in terms of overall market capitalization, upending some of its tech rivals in the process and finishing the year in the top spot for the first time since 2002. The way it's achieved those heights is by reinventing itself as a subscription-based software provider, offering key platforms like its Office productivity software suite to users on a monthly basis rather than solely selling one-time licenses that required users to upgrade at later dates in order to get updated features. Millions of customers have decided that having the latest access to the newest software features is worth what turns out to be higher costs than simply buying a one-time license and hanging onto the software for a long time, and that's sent Microsoft profits soaring. Moreover, by offering key software to users of operating systems other than Windows -- especially iOS -- Microsoft has tapped into a much larger customer base and reaped the rewards accordingly.

What's ahead for the Dow in 2019?

Among these three stocks, Microsoft has the greatest potential for fast future growth in 2019. Even as some positive trends in the technology industry start to slow down and reverse course, Microsoft has the benefit of providing needed services to enterprise customers and individual consumers. Efforts to move into high-growth areas like cloud computing have also borne fruit and should continue to gain importance for the company.

For Merck and Pfizer, a lot depends on regulatory threats that could have a significant impact on the pharmaceutical industry. Many defensive investors turn to healthcare as a stalwart industry during economically troubled times, but these two stocks could give up ground if they can't find new and innovative treatments to keep their pipelines full of candidates likely to become tomorrow's blockbusters.

Investors want the Dow to rebound in 2019, and these stocks have a role to play. If the market bounces back, it might well be because these leaders continue to move higher over the next year.

Teresa Kersten, an employee of LinkedIn, a Microsoft subsidiary, is a member of The Motley Fool's board of directors. Dan Caplinger has no position in any of the stocks mentioned. The Motley Fool owns shares of Microsoft. The Motley Fool has a disclosure policy.