Look at any recent Apple revenue breakdown. If you pretend that the iPhone doesn't exist, Apple's most profitable market segment is services. Even the iPad and Mac can't dethrone it.
According to leaked BOMs, the iPhone usually has ~40% profit margins. It's very likely that Apple Music, the App Store and iCloud all turn >90% margins, which is basically free revenue to shareholders.