You're absolutely right, and you should follow this to its logical conclusion. Apple only does what's in its best interests. The company consistently acts to strengthen its brand whenever possible to make more money.
It's irrational to expect a corporation, whether it's Apple or any other entity, to act ethically. Every decision they make, from sponsoring LGBT events to pushing back against the FBI, is made carefully with their brand in mind. Imagine what would happened, for instance, if Apple hadn't pushed back against the FBI. Their customers would have been enraged, just as they are now.
The real question is this: What would you expect Apple to do as a shareholder?