A comment from Apple on the location tracking business was literally being anticipated. Steve Jobs spoke up a little on the matter replying to an email saying that other operating systems also track you, Apple doesn't track anyone and the information circulating around is false. Apple has since released a statement regarding the matter. They say that they aren't tracking the location of iPhones, they never have and they never will. They said that everyone's so worked up on this matter because it's a lot to explain and creators of this technology (including Apple) have not released enough education on this matter to date.
Apple speaks up
Apple maintains that they're not logging the location of iPhones. They say, “Rather, it’s (the iPhone) maintaining a database of Wi-Fi hotspots and cell towers around your current location, some of which may be located more than one hundred miles away from your iPhone, to help your iPhone rapidly and accurately calculate its location when requested. Calculating a phone’s location using just GPS satellite data can take up to several minutes. iPhone can reduce this time to just a few seconds by using Wi-Fi hotspot and cell tower data to quickly find GPS satellites, and even triangulate its location using just Wi-Fi hotspot and cell tower data when GPS is not available (such as indoors or in basements). These calculations are performed live on the iPhone using a crowd-sourced database of Wi-Fi hotspot and cell tower data that is generated by tens of millions of iPhones sending the geo-tagged locations of nearby Wi-Fi hotspots and cell towers in an anonymous and encrypted form to Apple.”
The crowd sourced database is too big to store on an iPhone and therefore they download an appropriate subset to each iPhone. The cache is protected, not encrypted and backed up to iTunes everytime you plug your phone in and sync. Apple plans to stop backing up this cache in an upcoming software update. The data sent to Apple is anonymous and encrypted which means that while data is going from your iPhone to Apple, they have no way of telling where it's coming from. There are two bugs with this feature though. The way Apple originally planned it, your iPhone wasn't supposed to store more than a week's data but some people find that they have upto a year's worth of information stored on their phone. This will be fixed with an upcoming software update. There have also been reports of the iPhone continuing to collect location information, despite location features being switched off. This too will be fixed in an upcoming software update.
Finally, the most important piece of the pie. What does Apple do with the information it receives. They say they provide anonymous crash logs to third party developers so they can de-bug their apps. Their iAds systems uses location to target their ads. Location information is not shared with any third party unless the user themself approves giving the location to the current ad.