Does the stock market feel overbought to you? After watching the benchmark S&P 500 index climb about 28% over the past year, nobody can blame value-conscious investors for thinking twice before buying any stocks these days.

The benchmark index is way up, but not all of its components have participated in the rally. Shares of Pfizer (PFE 0.65%) and Walgreens Boots Alliance (WBA -0.78%) have been beaten down more than 25% over the past 12 months.

Both of these dividend-paying stocks have been beaten down so far that they offer yields above 5% at recent prices. Here's a closer look to see if buying them on the dips is a smart move.

1. Walgreens Boots Alliance

Shares of Walgreens Boots Alliance have lost about 47% of their value over the past 12 months. The company had been steadily increasing its dividend payment for nearly 50 years. Sadly, a string of losses forced the retail pharmacy chain to slash its quarterly payout by 48% this year.

Walgreens stock has fallen far enough that its reduced payout works out to a 6.2% yield at recent prices. This year, management expects adjusted earnings to land in a range between $3.20 and $3.35 per share. This is more than enough to cover its dividend, which it recently reduced to $1.00 per share annually.

Walgreens' attempt to become more than a chain of retail pharmacies has been a disaster for its shareholders. In recent years, it plowed billions into VillageMD clinics that it opened next to hundreds of its pharmacies.

Walgreens and clinic-operation partner, Cigna, recorded a $12.4 billion impairment charge earlier this year related to VillageMD, and the partners are taking a big step back. Walgreens plans to close about 160 of those clinics.

Cutting costs by closing heaps of underperforming health clinics could give Walgreens an earnings boost over the next couple of years that the market isn't expecting. The stock is trading for less than five times management's adjusted earnings expectation for fiscal 2024.

While Walgreens looks like a bargain now, it's important to remember that it takes only a minute to tell your doctor you want to switch pharmacies. The retail pharmacy industry is so competitive that it's probably best to wait another year or two to see if Walgreens can use its size to its advantage and deliver a growing profit.

2. Pfizer

Investors expected sales of Pfizer's COVID-19 products to decline in the wake of the pandemic. But those losses have been much steeper than anticipated. First-quarter sales of Comirnaty, the company's COVID-19 vaccine, dropped 88%, and Paxlovid, an antiviral treatment, fell 50% year over year.

Pfizer reported total first-quarter revenue declined by 20% year over year and 42% from the first quarter of 2022.

While it looks like Pfizer's in deep trouble, it's important to remember big pharmaceutical companies are made of many pieces moving in opposite directions. If we exclude Comirnaty and Paxlovid, first-quarter sales rose 11% year over year.

The heaviest losses for Comirnaty and Paxlovid are already in the rear view, but Pfizer has plenty of new growth drivers to push total sales and earnings higher in the years ahead. Near the end of 2023, it acquired Seagen and its collection of cancer therapies.

One of the four marketed treatments Pfizer acquired from Seagen, Padcev has recently been approved to treat newly diagnosed patients with advanced-stage bladder cancer. Padcev sales could grow to more than $4 billion annually and there could be plenty more blockbusters on the way. The FDA approved a record nine new medicines from Pfizer last year.

Unlike Walgreens, Pfizer recently raised its dividend payout for the 15th year in a row. At recent prices, it offers a 5.8% dividend yield that's likely to keep growing on the back of all the new drugs it's been launching. Buying some shares on the dip and holding them long-term looks like a smart move for most investors.