https://www.pcworld.com/article/142272/accounting_rules_behi...Apple reports iPhone revenues over a 24 month period, this is called subscription accounting. Since an iPhone is sold as a subscription, Apple can write off services associated with providing that subscription on an ongoing basis, i.e. give all upgrades away for free.
http://tech.fortune.cnn.com/tag/subscription-accounting/
iPod Touch and Mac revenues do not use subscription accounting, therefore Apple is not allowed to give away major OS upgrades for these products, it must treat upgrades as separate products that make or lose money for themselves. Apple is not allowed to give away a major iPod Touch upgrade and apply the costs of writing the upgrade to its iPod Touch business.
I am certain of the rules around subscription accounting and its effect on requiring Apple to charge for iPod Touch and Mac OS upgrades (and Apple is happy to charge for OS X upgrades any ways).
Whether the $4.99 for XCode is a byproduct of these rules is conjecture. I think so, but I've looked all over and I can find neither my Apple Employee badge nor my Chartered Accountant diploma, so it's more than fair to doubt me on this.
p.s. Another clue to the reasons for the charge is contained in the fact that XCode is still free for ADC developers. Since ADC revenue is subscription-based, Apple can give away whatever it wants to ADC subscribers.