You don't need to pay to use Xcode, or to run apps on your own devices. If you publish to the app store I think there is a $99/year fee or something to have your app signed, plus they take 30% of your revenue.
You don't absolutely need to have your code signed, I can give apps to my friends, they just get a warning about it not being signed and potentially unsafe when it's first installed.
So? You need a computer to run any code at all. I bought a used Mac for very cheap last year, the first Apple product I've owned in ~35 years of working in and around the computer industry. I don't feel ripped off.
You don't absolutely need to have your code signed, I can give apps to my friends, they just get a warning about it not being signed and potentially unsafe when it's first installed.