Apple makes money on both hardware and software. So while all those manufacture have to pay for its OS ( Windows ) to M$, Apple gets those themselves as well with MacOS.
Which is why Apple is much more profitable when you are discounting Microsoft from that equation.
And If you are talking about Hardware, ( which by the way includes both component inside and exterior as well ), please makes an proper comparison before jumping in to say they are insanely expensive. While i am not saying that they are not, it is not a huge difference as some have put it.