The market is putting up a strong performance this year with the S&P 500 gaining 16% as of this writing. That's a far cry from what we saw for most of 2022 when equities experienced a painful downturn. But while things are looking up for many stocks, some are still struggling under the weight of company-specific issues.

That's the case with CVS Health (CVS -0.22%) and Etsy (ETSY 0.34%). Both companies are trading near their 52-week lows, but both are worth buying, at least for long-term investors. Here's why. 

1. CVS Health 

CVS Health has encountered several issues this year. First, the company's financial results have failed to impress investors. In the second quarter, sales grew by 10.3% year over year to $88.9 billion. However, the company's adjusted earnings per share dropped to $2.21, down from the $2.53 reported in the year-ago period.

Second, CVS recently lost some key client business. Blue Shield California, a non-profit health insurance provider, unveiled a plan to expand the list of pharmacy benefits managers it relies on, decreasing its exposure to CVS.

These problems are responsible for CVS' poor performance this year, but there is hope, especially for investors willing to hold the company's shares for a while. It is difficult to discount CVS' deep footprints across the U.S. as a leading pharmacy patients trust to regularly fulfill prescription medications. But that's just one aspect of the company's overall business.

CVS has been making important changes over the past few years, substantially diversifying its business. It has a major insurance division and is also in the primary care business. Further, CVS announced last month that it would launch a new subsidiary called Cordavis that will manufacture generic drugs. On the one hand, the generic drugs market has been somewhat sluggish due to stiff competition, relatively low barriers to entry, and the difficulty of building an economic moat.

But the move is a great one for CVS as it allows it to further diversify its deep health-based ecosystem by offering generics -- something many of its customers will want, considering that most adults in the U.S. think the prices of medicines are too high. That's an advantage CVS will have over other generic drug manufacturers -- the benefit of its brand name and the millions of patients familiar with it.

Lastly, CVS is a good dividend stock. The company has raised its payouts by almost 169% in the past decade, which isn't bad at all. It offers a competitive yield of 3.69% and a low cash payout ratio of about 17%.

CVS may be facing near-term issues, but the company's solid position in the everlasting healthcare sector and diversified business are important tools that should allow it to bounce back from recent troubles and still deliver excellent results over time. That's why it's worth buying CVS shares, especially near their 52-week lows. 

2. Etsy

Etsy is a leader in the e-commerce sector, but the company isn't performing very well right now. There are at least two potential reasons. First, the e-commerce industry has slowed considerably since the earlier days of the pandemic, when it experienced a boom. Second, Etsy is best known for offering vintage, handmade, and rare goods, many of which are pricey. The economy still isn't doing great right now despite some improvement.

Consumers aren't lining up to spend money on the kinds of goods that Etsy offers. In the second quarter, the company's revenue increased by just 7.5% year over year to $628.9 billion. Etsy's gross merchandise sales -- the total dollar value of transactions conducted on its platform -- declined by just under 1% year over year to $3 billion. Etsy's net income declined by 15.3% year over year to $61.9 million.

One thing investors are learning about Etsy is that like many highly successful companies, its business is susceptible to economic cycles. But Etsy's business can recover and perform well over the long run thanks to its position in a high-growth industry. E-commerce will continue to gain traction. It's hard to know when it will peak, but e-commerce sales accounted for just 15.4% of total U.S. retail sales in the second quarter.

There is likely still ample room for growth. Etsy dominates its niche of the industry -- vintage, handmade, and rare items. The company has strengthened its position over time with various acquisitions. That includes the acquisition of Depop, a Gen Z-focused unique fashion community, and Reverb, a platform that offers vintage music instruments.

Both companies fit seamlessly into Etsy's long-term plan and arguably helped it strengthen its network effect. Etsy's competitive advantage will make it hard for its peers to knock it off its solid position in this market for a while. The company's results will improve along with the economy, too, and allow it to make headway into its massive $2 trillion total addressable market, where it has barely scratched the surface.

In short, Etsy might be down right now, but astute investors should strongly consider buying shares of the company.