Nice try to rewrite history, but the Chinese government didn't have a problem with Google doing targeted advertising, they had a problem with Google not wanting censor search results. Sergey Brin, who grew up in the Soviet Union, was adamant about not kowtowing to this. It didn't help that there were state level attempts to hack into humanitarian activist accounts.
Technically, Google didn't "leave" China either, they simply moved Google.cn to Hong Kong. The fact that mainland Chinese can't easily access Google without VPNs (now banned, helped along by Apple) is a political decision and doesn't have anything to do with Google. No one in the world has problems using Google.hk except those in the mainland.
Apple's behavior here is quite unethical no matter how you slice it. They are aiding and abetting a censorship regime that is cracking down even harder recently than it was previously. The centralized app store model makes it even worse, rather than better, as on the PC and Android, you can still side load apps or run linux, in order to avoid government mandated surveillance and censorship (In Xinjiang province, the government recently went as far as to mandate everyone install a backdoor or face jail time and fines)
Just wanting to sell things to people isn't an excuse, if in doing so, you are lending credibility and legitimacy to a unethical behavior. And frankly, the asymmetrical way many Western tech and media companies are blocked in China is frankly an unfair trade practice. Wasn't joining the WTO supposed to come with some kind of tit-for-tat agreements? That in exchange for lowering of tariffs and import regulations, there has to be some reciprocity on the other side?
Apple can still make their phones in China, but if they had a backbone, they'd say, no, "open internet" does not mean "we will help ban all VPNs from our store so Chinese consumers have NO CHOICE." and refuse the order, and let China ban the App Store. They could then allow a side-load model that decentralizes control so that the government can't even force them to censor.
In the US, they've marketed themselves as being anti-surveillance and proudly implemented cryptographic techniques in ways that even they can't break them. Allowing Chinese to sideload apps would allow them to say to the government "we can't stop people from using VPNs, we can't control what they download and install via side loading"
Sadly, that ship may have sailed, but IMHO, standing for your principles is better than selling out for money. They've already got $200 billion in cash in the bank and aren't hurting for revenue.