When saving for retirement, you want to stash your money in a balanced and diversified portfolio of stocks that will appreciate in value over time, hopefully without making you lose sleep from daily price fluctuations.

Pharmacy companies like CVS Health (CVS -0.62%), Walgreens Boots Alliance (WBA -0.06%), and Rite Aid Corporation (RAD 5.56%) can potentially fit the bill, thanks to the fact that pharmacies aren't going to go out of style anytime soon. Plus, CVS Health and Walgreens Boots Alliance pay dividends and all three have been around a long time, thereby proving that their business model is sustainable -- or so the logic goes. But, in my opinion, the issue is a lot more complicated. Let's take a closer look at why these companies don't look like winners for retirement savings.

A pharmacist holds a tablet while looking at shelves of medication in a pharmacy.

Image source: Getty Images.

Don't expect to beat the market

It's critical to stay realistic about what certain stocks could do for your portfolio over time. After all, it's impossible to maintain a balanced portfolio if you don't understand where each of your holdings falls within the balance of risks and returns.

With these three pharmacy stocks, you shouldn't anticipate rapid growth or even keeping pace with the market's average. 

Take a look at this chart:

^SPX Chart

^SPX data by YCharts

That's right, over the past 20 years, only the total return of CVS outperformed the market, and the other two stocks massively underperformed, with Rite Aid losing most of its value. What's more, over the past 10 years, none of the trio came anywhere close to beating the market. 

In other words, you'd have done much better by buying an index fund or a diversified ETF, which is one strike against these pharmacy stocks.

You won't get rich on the dividends

Some investors might be attracted to the dividends paid by pharmacy stocks. As dividends (hopefully) get hiked over time, early investors should see higher and higher returns which can then be reinvested or simply withdrawn.

But history throws shade on this argument for buying pharmacy stocks. Once again, you'd have done better with dividend growth over the past several years just by buying a dividend-themed ETF or a market-tracking ETF, as shown in the chart below:

CVS Dividend Chart

CVS Dividend data by YCharts.

Buying ProShares S&P 500 Dividend Aristocrats ETF would have given you significantly more dividend growth and a much higher total return over the last five years, though its current dividend yield is slightly lower than CVS'.

And there isn't very much dividend hiking going on with either of the two pharmacies on the chart. In a nutshell, pharmacy companies haven't been able to raise their dividends very quickly because their revenue and cash flows haven't been soaring.

But are they safer?

Could pharmacy stocks make up for their slow growth by having profit margins that are extra safe? Fat margins could lead to their having more cash and leave the door open to share repurchases, which often pump up stock prices, not to mention provide investors with a measure of confidence in the ongoing health of the business. So, if wide margins were a given, pharmacy stocks might still have a place in retirement portfolios.

But, as it turns out, pharmacies have profit margins that are incredibly thin, and they're also getting eroded over time.

CVS Profit Margin Chart

CVS Profit Margin data by YCharts.

Of the three pharmacies I've mentioned, only Walgreens has improved its net margin over the previous 10 years, and Rite Aid's has collapsed into unprofitability. If major players like CVS can't maintain a set level of profitability over the years, it's yet another strike against pharmacy stocks being safe and suitable for retirement savings.

I wouldn't recommend using pharmacy stocks to anchor your portfolio while you're building up a nest egg to retire on. There are better options, such as set-it-and-forget-it index funds or dividend-themed ETFs.