Most stocks fall when the major market indexes sink. That makes sense. But there are exceptions. 

Some of the outliers will only be able to outperform the market on a temporary basis. However, some are also great picks for the long term. Here are three such stocks to buy now that are beating the market.

1. Vertex Pharmaceuticals

Vertex Pharmaceuticals (VRTX 0.20%) isn't merely beating the market; the biotech stock is trouncing it. So far this year, Vertex's share price has skyrocketed by more than 30%.

None of the underlying factors behind the overall market decline affect Vertex very much. Physicians won't stop prescribing the company's cystic fibrosis (CF) drugs because inflation is high or interest rates are rising. 

Vertex arguably ranks as the best biotech stock on the market right now -- and not just because of its sizzling year-to-date performance. The company has a clear path to growth for its CF franchise by continuing to secure additional reimbursement deals and approvals in younger age groups. 

Even better, Vertex's pipeline could produce several big winners in the near future. The company expects to file for approvals of exa-cel in treating sickle cell disease and beta thalassemia later this year. It also has promising programs either already in or soon to be in late-stage testing, with VX-147 in treating APOL1-mediated kidney disease and VX-548 in treating acute pain.

2. Dollar General

Many retail stocks are struggling, but not Dollar General (DG -0.59%). Shares of the discount retailer have risen 7% year to date. That's an impressive gain considering that the S&P 500 continues to flirt with bear market territory.

It's not all that surprising that Dollar General is faring well during these tumultuous times. With inflation near 40-year highs, consumers are opting to shop for bargains. Dollar General's everyday low pricing is understandably attractive in this environment.

The company also has a significant competitive advantage, with its 18,000-plus stores located within five miles of roughly 75% of the U.S. population. This convenience makes a big difference with gas prices so high.

But can Dollar General continue to perform well when the economic outlook is more upbeat? Probably so. The stock trounced the market over the past three-year, five-year, and 10-year periods. Dollar General should be well-positioned for future growth as well, with its strategy of focusing more on refrigerated and frozen products.

3. UnitedHealth Group

You might think that health insurance stocks would be boring. That's not the case with UnitedHealth Group (UNH 1.61%). It has handily beaten the market in recent years and continues to do so thus far in 2022.

UnitedHealth Group's stable underlying business is appealing to investors during times of uncertainty. The company is able to relatively easily pass along higher costs to customers. Its dividend, which currently yields close to 1.3%, is an added bonus for risk-averse investors.

Health insurance remains the biggest revenue generator for UnitedHealth Group. More than 78% of the company's first-quarter revenue stemmed from its insurance business. Medicare plans should continue to serve as a growth driver over the next decade as an increasing number of Americans reach age 65.

But the biggest opportunity for UnitedHealth Group lies with its Optum business. Optum's health services include analytics, technology, and pharmacy benefits management. These businesses are much more profitable than UnitedHealth Group's health insurance business is.

Optum is also expanding into new areas. It hopes to close on an acquisition of LHC Group later this year. This transaction will make Optum a leader in the home healthcare market.