No, Apple is a 'full-stack' tech company. People buy their products both for their hardware and software. If they were just a hardware company, why would they bother making macOS, iOS, iMessage, Safari etc?
Haven’t you heard people whine about how Apple is so much about privacy but they take money from Google to have it as the default search?
They don’t have Google as the default search because of the money, they have it because they think it is the best. Even despite the privacy problems and the control this grants Google.
How does a maps service sell more hardware? Because using their own maps service Apple can completely control the experience.
Now maps was hard and search is much harder still so we may very well never see this released. But even then they can use this as leverage while negotiating with Google, both for money and for control.
Because your claim about them being a hardware company is incorrect.
They market themselves as a privacy focused company. Privacy is all about software and services, not hardware. Search is something they could add to their portfolio to strengthen their privacy stance.
Services are ca. 18% of Apple’s revenue, after years of huge spending and tons of dedicated effort to grow this segment. The fact that it is as high as a fifth is itself a monumental feat.
Hardware sales of the iPhone alone, excluding all computers, AirPods, and iPads, is over 40%.
The same reason why having a maps product benefits them. They want to have complete end-to-end control over a user's experience on their device, well beyond just the hardware. Having their biggest competitor dictate what happens whenever someone opens the web browser on an iPhone is a massive hole.
Hard drives are cheap enough that storing the index itself is the least expensive part of building it. Engineer time to make that index usable for a search engine is that much money every week.
One of the selling points of apple devices is getting away from google spyware. Every bit of spyware they can prevent the user from being exposed to is better.
Apple doesn’t care at all about the most common types of spyware. Nearly every app in the iOS App Store contains tons of spyware.
Apple’s view is that you consented to this sort of unaccountable invisible tracking by dozens of third parties (against whom you have zero recourse), when you agreed to the TOS of the App Store.