Yes but macOS is a large part of the appeal of getting a Mac in the first place and Macs have really healthy margins for the industry, ergo it's making money and isn't free as such. It plus seven years or so of upgrades are built into the price.
They also do not directly sell iOS or its upgrades but we'd hardly say iOS isn't making money.
They also do not directly sell iOS or its upgrades but we'd hardly say iOS isn't making money.