This earnings season, multiple companies have reported quarters burdened by economic headwinds, low consumer demand, and foreign exchange challenges. But these temporary obstacles present a buying opportunity for stocks with excellent long-term outlooks.

Market declines over the last year highlight the importance of investing in stocks that will likely soar over five-plus years. Apple (AAPL 0.51%), Microsoft (MSFT 0.46%), and Warner Bros. Discovery (WBD 0.83%) had to contend with a variety of challenges over the last year, but remain no-brainer buys. Here's why.

1. Apple

On Feb. 2, Apple posted its first-quarter 2023 earnings, reporting its first year-over-year sales decline since 2019. Revenue in the quarter fell 5.5% year over year to $117.15 billion, while operating income tumbled 13% to $36 billion.

The declines were primarily due to production issues in China at the factory that manufactures about 70% of all iPhones, as well as currency fluctuations resulting in an unusually strong dollar.

Despite pitfalls in product segments, Apple's services business continued to grow, with revenue rising 6.4% year over year to an all-time high of $20.76 billion. The subscription-based business once again offered attractive profit margins, reporting 70.8% compared to the product segment's 37% profit margins. 

Apple clearly stumbled in its latest quarter. But its stock is up 276% in the last five years and 830% in the last decade. Meanwhile, its annual revenue climbed 48% to $394.3 billion since 2018, and operating income increased 68% to $119.4 billion. As a result, holding Apple shares over many years can mitigate short-term headwinds and provide consistent gains. 

Moreover, the company has some exciting developments ahead, such as reducing its dependency on other tech companies for iPhone components and a reported venture into augmented/virtual reality with a new headset this year. Apple looks to have a fruitful long-term future, making it a no-brainer buy this February. 

2. Microsoft

Microsoft's Q2 of 2023 earnings report showed a 2% year-over-year rise in revenue of $52.7 billion and an 8% decline in operating income to $20.4 billion. The company continued to suffer from the declining PC market, with revenue in its more-personal computing segment falling 19% year over year to $14.2 billion. 

But Microsoft's stock is an obvious buy, thanks to its leading position in multiple lucrative industries that will likely have consistent long-term growth. For instance, the company's cloud computing service Azure boosted revenue in its intelligent cloud segment by 18% to $21.5 billion in the second quarter of 2023.

While growth slowed after the segment reported a 20% increase in the first quarter of 2023, Microsoft has big plans to further develop Azure and boost profits well into the future.

Last November, CEO Satya Nadella said Microsoft would be building data centers in 11 new regions, with the company especially bullish about Asia. The goal is to grow its market share in cloud computing, an industry worth $368.97 billion in 2021 with an expected compound annual growth rate of 15.7% through 2030, according to Grand View Research.

Microsoft also is expanding its position in the booming artificial intelligence (AI) segment with its investment in tech start-up OpenAI -- which further strengthens the stock as a must-buy for the long haul. 

3. Warner Bros. Discovery

After a year where Warner Bros. stock plunged over 62%, its shares have skyrocketed since Jan. 1. The entertainment company's stock increased 68% year to date as investors grew optimistic about its 2023 prospects. But it's still far from its previous ceiling, with shares down 42% year over year.

As the home of film/TV franchises such as Harry Potter, Game of Thrones, DC superheroes, and The Lord of the Rings, the company should seemingly be flourishing. However, a pricy merger and restructuring costs in 2022 hurt earnings.

Despite the challenging year, the outlook over the next five to 10 years is promising, making now a perfect time to buy. Warner Bros. Discovery says this year will be focused on "relaunching and building" following the content slashes that defined its business in 2022.

In the coming months, the company plans to unveil its newly merged HBO Max and Discovery+ streaming service and release multiple blockbusters such as DC's sequel to Shazam!, Dune: Part Two, and Aquaman and The Lost Kingdom.

And on Feb. 10, Warner Bros.will launch the highly anticipated Harry Potter-themed video game Hogwarts Legacy across consoles and PC. After two delays due to COVID-19, the game will likely provide a nice boost to revenue. 

Warner Bros. Discovery had a troubling first year of business. But its average 12-month price target of $21.21 offers 32.6% growth. Add to that a promising long-term outlook, and stock looks like a no-brainer buy.