Health-care stocks—a great long-term market bet

As well as the S&P 500 has done over the last five years, there's one sector that's vastly outperformed the rest. Since June 2010, the S&P 500 health-care sector has climbed a whopping 162 percent. That's significantly more than the S&P 500, which is up 97 percent over that time, and it's nicely ahead of the second best-performing sector—consumer discretionary—which rose by 141 percent.

The health-care sector dominance is continuing, with year-to-date returns of 8.8 percent, the best performance of any sector, and there's good historical reason to believe the run won't be ending.

Healthcare
Jose Luis Pelaez I Blend Images | Getty Images

Dating back to 1990, the S&P 500 Index has risen only 1.6 percent on an annualized basis during the May–October period, relatively weak compared to other six-month periods. However, the health-care sector has risen 5.2 percent, the strongest of the 10 S&P 500 sectors. It's outperformed the broader market 65 percent of the time from May to October.

Many investors likely missed out on the early post-recession gains and may have forgotten about getting back into the health-care sector—for understandable reasons. In 2010, the health-care industry was in turmoil. President Barack Obama had just signed the Affordable Care Act into law, and there was significant uncertainty around how this would impact the industry. That year, health care wasn't just the worst-performing sector—it was the only one to post negative returns.

Read MoreThe health-care sleeper stock niche that has a global growth plan

Slowly but surely, though, it became clear that the Affordable Care Act was going to boost company bottom lines, not hurt them. About 17 million have signed up for heath-care insurance since the exchanges opened in October 2013, and that's resulted in billions of more dollars for hospitals, pharmaceutical companies, medical device operations and more.

"Obamacare gave the industry a bit of a scare, but as Americans who previously didn't have coverage begin to obtain coverage, it's becoming a tailwind," said Stephan Patten, deputy chief investment officer at Sectoral Asset Management, a Montreal-based firm that specializes in health-care investments.

"Fundamentally, the industry is doing well. People can still get in the market and make money today." -Jeff Loo, S&P Capital IQ health-care analyst

Advances in biotech have also boosted the health-care sector performance. In each year over the last four years, biotech has been the best-performing niche by a wide margin.

A lot has changed since the late 1990s, when the biotech space went through a boom-and-bust cycle, much like the tech sector. Back then returns were rooted more in expectations than results. Biology-based drugs, as opposed to more traditional chemistry-focused ones, were expected to treat ailments that could never be treated before, but there wasn't much science to back the excitement up.

John Schroer, head of health care at Allianz Global Investors, said that in 2003 the human genome—critical to biology drugs—was finally fully mapped out. Regulators have also made the drug-approval process easier, and that's dramatically sped up the time it takes to get a drug from concept to shelf. Companies are also more focused on creating treatments for specific cancers and diseases rather than trying to make something for the masses. That allows them to develop numerous drugs and also sell them at a higher price.

"There's been this (renewed) understanding of diseases at a greater level," Schroer said.

Read MoreThe action in cancer drugs is hard to keep up with

These medicines also have massive sales potential, according to Jeff Loo, a health-care analyst with S&P Capital IQ. At the moment, there are between 10 and 12 biotech drugs in the industry pipeline that have the potential to earn at least $1 billion in revenues, Loo said. Last year Gilead Sciences made about $10 billion on a groundbreaking hepatitis-C drug, Sovaldi, and it could bring in $13 billion more in 2015, Loo said. He expects to see double-digit revenue expansion in the biotech space over the next few years.

While the sector has certainty rebounded since 2010, valuations aren't unreasonable for what's considered a more growth-oriented sector, in Loo's analysis. He pointed out that health-care stocks on the S&P 500 are trading at 18.5 times earnings, compared to 17.9 times for the overall index.

"That's a small premium," Loo said.

The real boom

The sector should continue to see steady growth over the next few years as more Americans are now receiving insured treatments and boomers are going to need more drugs and medical services as they age.

While someone can buy a general health care ETF, investors may also want to buy into specific sub-sectors. There are number of sub industries that have different growth profiles and prospects. The main ones are biotech, pharmaceutical, medical device technology, hospitals and health care insurers.

For investors who want to play it safe, large, diversified pharmaceutical companies are the way to go, said Rob Cavallo, an analyst at RBC Global Asset Management. In the 2000s, these companies were out of favor—their pipelines were stagnant and a number of their high-performing drugs went off patent—but they're reinvesting themselves, Cavallo said.

They have more capital discipline, they care more about shareholders—many pay dividends—and their drug pipeline has been refreshed. Their size, though, allows them to make mistakes without sinking the company. Biotech firms, which are more growth-oriented, tend to make big gets on one or two drugs. The payoff can be big if things go right, but returns could plummet if they don't.

Read MoreDividend stock bargains created by the latest Fed taper tantrum

More conservative investors may also want to look at health insurers, which should see more growth from Medicaid, Medicare and increased use of health-care exchanges, Schroer said.

One health-care niche that may not continue its run is hospitals. While this subsector will still see some growth, its post-Obamacare push is likely over, Schroer said. Over the last three years, it saw about 2 percent to 3 percent margin boost per year, thanks to the Affordable Care Act.

"That benefit is now in the rearview mirror, and hospitals will go back to their normal historical growth rate," Schroer said. "I don't foresee them having the same performance over the next three years."

Risks on the horizon

Raymond Mawhinney, a senior portfolio manager at RBC Global Asset Management, said drug pricing can be a major risk factor. Biotech drugs tend to be fairly expensive, and the government could force costs to come down. Sovaldi has become a lightning rod for criticism of drug costs.

There's also a growing "biosimilar" industry, which is essentially companies producing generic versions of biology-based treatments. As the pharmaceutical industry has seen, businesses make a lot less money on a drug when there's a generic alternative.

M&A activity is also picking up again. Last Friday, shares of health insurer Humana popped by 20 percent on rumors of a big acquisition in the works by a competitor. Teva Pharmaceuticals, the largest generic drugs company, has been involved in a hostile takeover bid for rival Mylan. This action worries Mawhinney.

"There are two points in the cycle where you see M&A activity—near the bottom and near the top," he said. "We're not quite there yet, but anytime you see more and more M&A, it tells we're well along in a cycle."

Read MoreObamacare unravel could be lose-lose situation

There's also a lawsuit, currently in front of the Supreme Court, that could force 13 million people to lose their federal health-care insurance subsidies, while a Republican win in the 2016 election could negatively impact the act.

However, if the long-term drivers and the performance pattern since 1990 hold true and the biotech and pharmaceutical pipelines stay healthy, then investors will still be able to get solid returns.

"Fundamentally, the industry is doing well," Loo said. "People can still get in the market and make money today."

By Bryan Borzykowksi, special to CNBC.com