The stock market can seem like a scary place right now. Even some of the most rock-solid companies in the market are seeing turbulence in their share prices, and with uncertainty surrounding the economy, interest rates, and inflation, the market could remain volatile for the foreseeable future.

However, there are some stocks you can buy that can't completely avoid market volatility but can help you sleep better at night knowing that your capital is invested in a business that should perform quite well over the next five, 10, or 20 years -- no matter what the economy does.

Realty Income (O 0.52%) is one such investment. This real estate investment trust, or REIT, isn't immune to market swings but is designed to produce year after year of predictable and growing income. In fact, because of market swings, Realty Income has become extremely attractive as a long-term investment.

Realty Income's business: Designed for good times and bad

Realty Income is a REIT that focuses on net-leased properties. If you aren't familiar with the term, a net lease is a type of lease agreement that requires the tenant to cover insurance, taxes, and most maintenance costs. In short, the tenant -- not the landlord -- is responsible for the variable costs of ownership. Net-lease tenants typically sign long-term leases (10 years to 15 years) with annual rent increases built in. They are designed for predictable and growing income over time.

Realty Income owns more than 12,400 properties, and about 80% of its tenants (by rental income) are retail in nature. But it's important to realize this isn't just any retail: Realty Income typically buys properties with tenants already in place, and most are hand-picked because they are resistant to recessions, e-commerce headwinds, or both.

Specifically, the bulk of Realty Income's retail tenants fit into one or more of three categories:

  • Discount: Not only do discount-oriented retailers tend to do as well or better during recessions, but they often sell items at prices e-commerce retailers can't match. Dollar stores are a major Realty Income property type and are a great example.
  • Non-discretionary: Businesses that sell things people need tend to hold up well during recessions. Drug stores like Realty Income tenant Walgreens (NASDAQ: WBA) are a good example.
  • Service: Businesses that sell services as opposed to physical items are inherently not easily disrupted by e-commerce, and many provide essential services that people need in good times and bad. For example, FedEx (NYSE: FDX) is a top Realty Income tenant.

In addition to the retail portfolio, Realty Income also owns industrial, agricultural, and gaming properties. But retail is definitely the focus.

This model is designed for steady value creation and income over time. And the proof is in the numbers. In 29 years as a publicly traded company, Realty Income has produced a 14.6% annualized total return for investors, handily beating the S&P 500. For income investors, not only does Realty Income have a 5% dividend yield that it pays in monthly installments, but it has increased the payout for 102 quarters in a row.

A rare opportunity to buy on sale

To be fair, Realty Income is still not a cheap stock. But it's certainly cheaper than it usually is now that it's about 20% below its 52-week high.

The stock trades for about 15 times 2023 funds from operations (FFO) -- the real estate equivalent of "earnings," which is a low valuation historically for Realty Income but isn't the lowest valuation in its peer group. However, when you consider the quality of its portfolio and the outstanding track record of delivering for investors, this looks like an excellent time for patient long-term investors to buy shares.