Apple’s a publicly-held company, and China is among the largest markets for consumer electronics. Apple’s shareholders wouldn’t be too pleased if Apple simply said “nah” to such a market, and Apple’s obligations are ultimately to its shareholders.
The situation might be different if Apple was a different kind of company, but it is what it is.