Health care, one of the largest and most complex sectors, is comprised of a broad range of companies that sell medical products and services. The health care sector includes companies that sell drugs, medical devices, and insurance, as well as hospitals and health care providers.

Some of the largest health care companies in the world include Johnson & Johnson (JNJ), Pfizer Inc. (PFE), and Merck & Co. Inc. (MRK). Health care stocks, as represented by the Health Care Select Sector SPDR ETF (XLV), have outperformed the broader market, providing investors with a total return of 16.3% compared to the S&P 500's total return of 5.9% over the past 12 months.1 In 2020, health care stocks have recouped nearly all of their losses since their March plunge while the broader market continues to suffer from the global coronavirus pandemic. Investors can thank health care stocks for a chunk of the stock market's rally.

The S&P 500 healthcare sector has risen 33.5% since March 23, when the S&P 500 hit its recent low. That beats the broader index's 32% gain in the same period. Both small and large companies have benefited from investor hopes that a Covid-19 vaccine or treatment is on the way.

See here: Shares of Moderna (MRNA), which last week touted positive early results for its coronavirus vaccine, have spiked 253% year-to-date, even though the company doesn't sell any products yet. It's now valued at more than $26 billion.

Meanwhile, stock in AstraZeneca (AZN) has jumped more than 18%. The British drug company is working with Oxford University on a vaccine, with deliveries potentially starting in September. It was announced last week that the US government has pledged up to $1.2 billion to accelerate development and secure 300 million doses.

But these products are a gamble for both investors and the companies testing them, with stocks remaining vulnerable to any news out of clinical trials.

Optimism over coronavirus drugs isn't the only factor driving health care stocks higher, Wells Fargo equity analyst Christopher Harvey told me. They've also benefited from investors looking to make more defensive plays during a recession.

"What we've seen during the selloff is health care has provided some really good downside protection," Harvey said. He also noted that health care stocks now make up a much larger proportion of low-volatility exchange-traded funds, which helps drive money toward the sector.

Nick Raich, CEO of The Earnings Scout, said health care stocks are actually cheap compared to the rest of the market. The health care sector is trading at nearly 16 times projected earnings over the next 12 months, while the S&P 500 is trading at more than 20 times projected earnings — in part because health care earnings have held up better than most.

"This is a trend that should persist in the post-[Covid] world and as hospitals open back up for full business," Raich said.

Harvey also noted that political headwinds the industry has faced in the past — namely criticism over high drug prices — have dissipated as drugmakers step up to provide essential services during a health crisis.

Although health care stocks on the whole have remained solid picks through the pandemic, some individual names remain tricky bets. Medical device makers may struggle if people need to keep postponing elective surgeries. And the biotech sector is notoriously up and down.

"It's hard to know if drugs are going to work — and even if they do work, it's hard to know how that's going to project to the market," Raymond James analyst Steven Seedhouse said.