You're paying for the brand, design, etc. Yes, Apple funds OS development though other sales, but it's not sold separately and new OS releases are free. As far as I understand the law, I can legally install macOS on a machine that did not originally come with it installed (hackintosh), with the caveat that I violate Apple's EULA by doing so.
Microsoft bundles all sorts of software with their OS that can be installed separately for free, does that mean they're actually not free because development is funded through other product sales? A lot of their services have a free tier, are those services not free because there's a paid tier?
Apple's inflated hardware price certainly includes room for funding their OS development, but that doesn't mean the OS isn't free. Windows sales also likely go toward funding things other than OS development, but that doesn't mean that all of their products aren't free if you're running them on Windows.