It's rarely a bad idea to consider buying Apple's (AAPL -0.65%) stock. Shares have soared 217% in the last five years and 900% over the last decade. It has dominating positions in several areas of tech thanks to the immense brand loyalty the company built with consumers, which has boosted its stock over the long term. 

However, Apple hasn't had it easy in 2023. The company reported three consecutive quarters of revenue declines as macroeconomic headwinds curbed consumer spending. Apple continued to outperform its competitors in product sales but has been unable to deliver growth. As a result, you might wonder if the company is still worth an investment. 

Despite the setbacks, Apple remains an excellent option for long-term-minded investors. Here's why.

A tumbling stock price

Shares in Apple dropped more than 11% since its third quarter of 2023 earnings release at the start of August. Revenue fell 1% year over year during the quarter, with declines in iPhone, Mac, and iPad segments. Dwindling iPhone sales made stockholders particularly uneasy, as the smartphone accounts for nearly 50% of the company's total revenue.

However, stock declines across the market suggest decreasing excitement for tech in general. The growth potential for industries like artificial intelligence (AI) and virtual/augmented reality (VR/AR) sent many stocks skyrocketing in the first half of 2023.

Yet, the chart below shows companies across the tech industry have experienced declines in share prices since Aug. 1. Wall Street seems to know that while these companies and their sectors have solid long-term outlooks, macro factors may continue to pose challenges over the next year. 

GOOG Chart

Data by YCharts

The good news is recent declines essentially put Apple's stock on sale. Its price-to-earnings ratio (P/E) of about 29 is at one of its lowest points in the last three months. The company's P/E is also lower than all of the companies above except for Alphabet, making it one of the cheapest ways to invest in tech. Poor economic conditions won't last forever, and a long-term investment in Apple could offer significant gains as the company recovers. 

Apple is diversifying in multiple areas

In addition to an attractive stock price, Apple is gradually strengthening its business with diversification. Its product lineup will expand next year with the release of the Vision Pro, the company's first VR/AR headset. Meanwhile, Apple has ramped up its plan to increase manufacturing outside of China by heavily investing in India. 

A Bloomberg report from this week reveals Apple surpassed $7 billion in production in India and aims to hit $40 billion within the next five years. The company is now manufacturing 2023's iPhone 15 in the country, with plans to start AirPod production there next year. The move reduces Apple's supply chain risk by decreasing its dependency on China. 

Moreover, the tech giant is further fortifying its future earnings with a massive expansion into digital services. Income from its App Store and subscription-based platforms like Apple TV+, Music, iCloud, and more allows the company to lean less on product sales during uncertain times.

The digital business has become an increasingly lucrative area for Apple. Profit margins for the services segment often hover around 70%, while products come in at 36%. Meanwhile, services has the potential to eventually surpass the iPhone as Apple's highest-earning segment. Services is currently its second-highest earning segment, and in fiscal 2022, services reported revenue growth of 14% year over year, double the iPhone's growth.

Then, in Q3 2023, services revenue growth hit 8% year over year, expanding more than any other part of Apple's business. Services' continued growth illustrates its resilience during economically challenging conditions, which bodes well for the company's long-term future. 

Apple shares may be on a downward trajectory for the rest of the year as it contends with reductions in consumer spending. However, its dominance in tech and its booming services business could offer substantial gains over the next five to 10 years as the market improves.

Apple is playing the long game, diversifying different areas of its business to secure its financial future. As a result, the company is worth investing in this month and potentially for the rest of the year if its stock continues to fall.