You realize both things can pay those salaries right? Paying customers subsidizing non-paying customers is rather common. Also you know free apps have in-app purchases right?
Not every free app has in-app purchases. My city, Seattle, has an app called Find-it, Fix-it where I can report potholes or abandoned cars. One Bus Away is an app that shows bus arrival times. I have grocery apps that show me what's on sale and give me digital coupons. None of these apps have in-app purchases.
Fewer than 1% of the apps in the store will have any effect whatsoever on Apple's hardware sales. Easily 99% of apps are long tail products that don't influence prior decision-making.
AS for margins, once you factor in Apple's high spending on R&D and engineering, their margins are fairly normal. Apple are financially successful because they sell high quantities and don't chase the extreme bottom of any market. Notice for example how they don't (currently) offer any mainstream external displays.