Three things come to mind:
1. Supporting a diverse ecosystem is hard and expensive. 2. It's easier to build a seamless platform when you have control over hardware and software. Look at Mac trackpad as an example; it's pretty much beats any PC trackpads. 3. Software sales is where the money is at. I used to work for a dell subsidiary and it was a common knowledge that Dell (and other vendors too) sold servers at a loss and made it up on software and support contracts. Apple has like ~80% profit margins on app store sales which is insane.