It's scary out there. And by "there" I mean the stock market. 

All of the major market indexes have entered bear market territory. Concerns are mounting that a full-blown recession could be on the way. Inflation remains frustratingly high.

Fear seems to be the prevailing emotion among many investors. That's understandable. However, you don't have to be trembling in your boots about every stock. Here are three stocks to buy if you're afraid of buying stocks.

1. Vertex Pharmaceuticals

The stock market's huge downturn so far this year hasn't impacted Vertex Pharmaceuticals (VRTX 0.20%) in the least. Shares of the big biotech have soared close to 30% year to date. Vertex could move even higher.

Inflation and the threat of a recession simply don't matter much to Vertex. The company markets the only drugs that treat the underlying cause of cystic fibrosis (CF). Its nearest rivals are years away from having even the possibility of launching competing therapies. The bottom line is that Vertex's CF drugs will continue raking in billions of dollars regardless of what happens with the stock market or the economy.

Even better, Vertex could have a new product beyond CF on the market relatively soon. The company and its partner, CRISPR Therapeutics, plan to begin filing for regulatory approvals of exa-cel in treating sickle cell disease and transfusion-dependent beta-thalassemia within the next few months. Exa-cel could become the first gene-editing therapy to reach the market.

Vertex's pipeline features two other late-stage candidates with blockbuster potential. The biotech also has an early-stage program that it thinks could lead to a cure for type 1 diabetes down the road.

The stock trades at a super-low price-to-earnings-to-growth (PEG) ratio of 0.38. With this attractive valuation and strong growth prospects, Vertex appears to easily rank among the best stocks to buy right now.

2. Dollar General

Consumers tighten their purse strings when the economy is bad. That's especially the case when inflation is also at levels not seen in more than 40 years. But this is exactly the scenario where Dollar General (DG -0.59%) thrives.

Granted, the discount retailer's share price is close to where it was at the beginning of 2022. However, you can count that as a big win with the dismal performance of the overall stock market.

Dollar General is practically recession-proof. Its business should pick up during an economic downturn. With the company's more than 18,500 stores located within five miles of roughly three-quarters of the U.S. population, high fuel prices could also work to its advantage. 

But the company doesn't require macroeconomic headwinds to be successful. Dollar General delivered strong growth during the boom years of the past decade. This is a stock that investors can feel comfortable owning during both good and bad times.

3. UnitedHealth Group 

UnitedHealth Group (UNH 1.61%) stands out as another recession-resistant stock that investors should like. The healthcare giant has been a master at passing along higher costs to its customers through the years.

Like Dollar General, UnitedHealth Group hasn't delivered jaw-dropping stock gains this year. However, unlike most other stocks, it's in positive territory.

The company is best known for its health insurance segment, which operates under the United Healthcare brand. This business is about as dependable as they come, generating strong cash flow year in and year out.

UnitedHealth's biggest growth driver, though, is its Optum segment. The segment provides value-based care, pharmacy benefit management services, healthcare technology services, and more.

Healthcare makes up nearly one-fifth of the U.S. economy. UnitedHealth Group ranks as the biggest healthcare company on the planet based on market cap. It's the kind of stock that's unlikely to cause investors to lose any sleep.