They pay for the hardware that they run Linux on. Apple's hardware division is very profitable without the "value" adds they run through their ecosystem, and those people never would have bought into the ecosystem whether they used MacOS or not.