So why did they buy Beats Audio?
Apple does care about its service business revenues, and I think they felt they needed to compete with Spotify, etc. instead of letting others slowly erode iTunes' share. This isn't about lock-in to iDevices -- Apple Music is also available on Windows, Android.
Apple has great gross margins on computers because they have such operational excellence in building them, but still a Mac makes much less margin than headphones- at any price point along the quality curve.
Accessories are just generally really profitable.