The S&P 500, which rallied roughly 16% this year, is hovering near its all-time high and looks historically expensive at 30 times earnings. Therefore, it might not seem like the best time to go shopping for new stocks.

But investors should also remember that a lot of the S&P 500's rally over the past few years was driven by a handful of high-growth tech stocks -- and that there are still plenty of undervalued stocks across that benchmark index that are worth buying.

Today, I'll take a closer look at two of my own stocks: Realty Income (O 1.60%) and Altria (MO -0.12%), which account for 4.3% and 3.8% of my portfolio, respectively. I'll explain why I bought them -- and why I think they're still great stocks to buy in this frothy market.

Colorful arrows emerge from a person's head.

Image source: Getty Images.

What do Realty Income and Altria do?

Realty Income is a real estate investment trust (REIT) that owns more than 15,600 properties across the U.S., U.K., and Europe. It mainly rents out its properties to recession-resistant retailers, and its top tenants include Walgreens, 7-Eleven, and Dollar Tree, but no single tenant accounts for more than 3.4% of its annualized rent.

Some of its tenants struggled with store closures in recent years, but Realty Income still kept its occupancy rate above 96% since its IPO in 1994. The growth of its stronger tenants -- like Dollar General, Walmart, and Home Depot -- largely offset that pressure. As an REIT, it splits that rental income with its investors -- and it must pay out at least 90% of its taxable income as dividends to maintain a favorable tax rate. It pays monthly dividends, and it's raised its payout a whopping 131 times since its public debut.

Altria, which was once known as Philip Morris USA, is the largest tobacco company in America. It spun off its overseas business as Philip Morris International (PM 0.28%) in 2008. At first glance, Altria might seem like a risky investment because smoking rates in the U.S. have steadily declined for at least the past eight decades. Its flagship Marlboro brand has also struggled to expand its slice of the shrinking retail market.

But to offset that slowdown, Altria consistently raised its prices, cut costs, and bought back more shares to boost its earnings per share (EPS) and protect its quarterly dividend -- which it's raised every year since it spun off PMI. It also diversified its portfolio with more brands of snus, nicotine pouches, e-cigarettes, and other non-smokable products.

Why will they attract more income investors?

When interest rates rose in 2022 and 2023, many income investors rotated from blue chip dividend stocks toward risk-free CDs and T-bills with higher yields. But as interest rates decline again, more investors should return to high-yield stocks like Realty Income and Altria.

Realty pays a forward dividend of $3.23 per share, which translates to a forward yield of 5.6%. It expects its adjusted funds from operations (FFO) per share -- which REITs use instead of their EPS to gauge their profitability -- to rise 1%-2% to $4.24-$4.28 this year and comfortably cover those dividends.

The Fed's upcoming interest rate cuts should also make it cheaper for Realty to buy more properties while reducing the macroeconomic headwinds for its tenants. And at $58, its stock looks dirt cheap at less than 14 times this year's projected AFFO per share.

Altria pays a forward dividend of $4.24 per share, which equals a hefty forward yield of 6.3%. It expects its adjusted EPS to increase 3%-5% to $5.35-$5.45 this year and easily cover that payout. At $67, its stock trades at just over 12 times the midpoint of that estimate.

Why is it the right time to buy these two stocks?

Realty Income and Altria aren't exciting stocks to own. But if you expect interest rates to decline over the next 12 months, then it's the perfect time to accumulate these two high-yield stocks. They both easily beat the 10-Year Treasury's 4.3% yield, and their low valuations should limit their downside potential if the broader market pulls back.