AT&T won't unlock iPhones cause they are HUGE moneymaker for them (minutes plus texts plus data plan) and because such a huge number of AT&T accounts come from the iPhone.
A huge number of iPhone accounts would just go to T-Mobile if AT&T unlocked them (AT&T is not that stupid)
Apple doesn't care in the least. Once you buy the iPhone, they have their only revenue from the iPhone sale/account. Apple gets no other revenue after that so Apple could care less if AT&T unlocked every iPhone they every sold.