Pharmaceutical giant AbbVie (ABBV -2.78%) has been one of the market's hottest stocks, rising more than 50% over the past year. It should raise eyebrows, considering the S&P 500 is up just 13% in that time. Why has AbbVie done so well and is it too late to benefit from buying shares?

Fear not -- AbbVie's rise has been a long time coming, and it's something that could have the legs to continue. However, there are some important details you need to be aware of. Here's why AbbVie could keep delivering excellent returns to long-term investors.

The stock is soaring; what gives?

AbbVie sells Humira, the world's top-selling pharmaceutical drug, which generated $20 billion in sales in 2021. It's the crown jewel of AbbVie's business and accounts for roughly 36% of total revenue. Humira is obviously important, but the drug's patent, which blocks competitors from creating a similar product, expires next year.

Patient speaking with a healthcare professional.

Image source: Getty Images.

This has long been on investors' minds, going back to the fall of 2021 when I covered AbbVie's share-price struggles and pointed the finger at fears over looming competition for Humira as a primary reason investors had cooled on the stock.

But AbbVie's business has continued growing in the meantime, which has steadily made the stock's valuation less expensive. AbbVie's price-to-earnings ratio (P/E) fell to the 8 to 10 range, well below the stock's median P/E ratio of 21 over the past decade. A valuation can sometimes be like a coiled spring, and when something happens to "unleash" that spring, it can have a remarkably strong effect on the stock.

Unleashing AbbVie's coiled spring

By this "coiled spring" analogy, I mean that sometimes the market gets it wrong. Investors viewed the loss of Humira as a potentially company-ruining event; you can see the market's sentiment reflected in shares selling off to such a depressed valuation. But the market then said, "Wait a minute, it's not as bad as it looks." Once this realization occurred, investors realized what a bargain the stock was and flocked to buy shares. The more depressed the valuation, the sharper the reversion back up will be, which is probably why AbbVie's been on such a tear.

So what happened to suddenly make the market love AbbVie again? The market is irrational in the short term, and you can't always explain the timing of things. However, AbbVie's management has been steadily preparing for life after Humira's patent expiration, evidenced by numerous developments in the business.

The company's massive $63 billion acquisition of Allergan in 2020 diversified AbbVie by adding several new products to its portfolio, including cosmetic surgery brand Botox. More recently, AbbVie acquired Syndesi Therapeutics for up to $1 billion, depending on product milestones. The acquisition bolsters AbbVie's pipeline of neuroscience products.

Internally, AbbVie has also made progress; its up-and-coming products Skyrizi and Rinvoq totaled $4.5 billion in revenue in 2021, growing more than 80% year over year. These drugs treat some of the same conditions as Humira. Don't forget that AbbVie will still sell Humira; the loss of patent protection means generic brands will enter the market, but Humira has an established brand that doctors and patients trust.

Analyst estimates expect an initial 6% drop in revenue for AbbVie next year, and then for the company to begin growing again in 2024 and beyond. In this light, Humira's patent expiration doesn't seem like some existential crisis at all.

Is there room to run?

This initial drop in business means that profits could fall next year. Analysts are looking for 2022 earnings-per-share (EPS) of $14.14 but expect that to decline to $12.23 in 2023. Even if we use next year's (lower) EPS estimates, the stock's current valuation is still just over 13, still well below that median P/E of 21.

The likely drop in Humira sales could create a drag on profit growth for the next several years. The company has grown EPS by an 11.5% annual average rate over the past decade, but analyst projections for the next three to five years call for just 2.5% per year. It's reasonable that the stock would see its valuation on the market fall in response to this slowdown.

So if you're looking for a quick buck, AbbVie may not be your stock. Shares could, of course, keep running higher, but there may be some uncertainty until investors see how the company performs once Humira's patent expires next year. For long-term investors, AbbVie's a proven blue-chip winner with a growing pipeline and a management intent on building for its next growth phase. I see Humira as an opportunity to buy shares while the company sets itself up for the long term.