It's well established that Apple's iPhone was in the works for a good two years before it became a household name at Macworld 2007, and interestingly enough, the idea to develop a phone in the first place was borne out of Apple's previous work on tablet prototypes in the early 2000s.
Steve Jobs admitted as much to Walt Mossberg and Kara Swisher during an appearance at the 2010 All Things D conference.
I’ll tell you a secret. It began with the tablet. I had this idea about having a glass display, a multitouch display you could type on with your fingers. I asked our people about it. And six months later, they came back with this amazing display. And I gave it to one of our really brilliant UI guys. He got [rubber band] scrolling working and some other things, and I thought, ‘my God, we can build a phone with this!’ So we put the tablet aside, and we went to work on the iPhone.
The idea to work on a full-fledged smartphone was of course made easier by Jobs' frustration with the Motorola ROKR, a joint venture between Apple and Motorola that aimed to be part iPod and part phone. When Jobs unveiled the ROKR in September 2005, he underwhelmingly called it an "iTunes Phone" and said Apple viewed the device as an "iPod shuffle right on your phone." Not exactly a strong sell.
Needless to say, the ROKR didn't exactly take the tech world by storm. And in what may be construed as a bit of unintended foreshadowing with respect to the ROKR, take a look at this video from Steve Jobs' September 2005 ROKR introduction where an on-stage demo meant to show how the device automatically resumes music playback once a call ends doesn't quite go as planned. Fast forward to about 3:09 into the video.
Putting those two factors together, Apple's iPhone was effectively the result of two factors; The lackluster product that was the ROKR and Apple's previous work on tablet devices.
Now based on previous reports and deposition testimony, we can say with reasonable certainty that iPhone development began in late 2004/early 2005. Indeed, a 2008 Wired article relayed that Apple's first meeting with Cingular (now AT&T) transpired in February of 2005 where Jobs discussed the notion of a "Motorola-free partnership".
And now, thanks to some digging through some Apple/Samsung court filings, we also have a better grasp as to when Apple's work on tablet prototypes began. What's more, I was able to dig up some photos of one of Apple's early tablet mockups from the early 2000s.
In December 2011, Samsung deposed Apple Senior VP of Industrial Design Jonathan Ive. While the full transcript of that deposition was filed under seal, a portion of it was recently released as part of a declaration from Apple's counsel regarding a Samsung motion seeking to file certain documents of the case under seal.