Short answer: it can’t get enough juice to charge the battery. The long answer is a little more complicated.
The USB specification is ever-changing. As I write this article (March 2009), there are two kinds of USB ports in common use – USB 1.0 and USB 2.0. USB 3.0 is set to debut fairly soon.
Among the major differences between the various versions of USB are how fast data is transferred using them and how much power flows through them. This is the source of the problem you’re encountering.
Many iMacs have USB 1.0 (or 1.1) ports. This means that they only work with devices that supply their own power, not those that need power sent to them via USB 2.0.
The iPhone is a USB 2.0 device, so it needs to draw power from the USB port – something the USB 1.1 ports on the keyboard can’t offer.
In order to get your iPhone battery the power it needs, plug it into a wall socket or the USB 2.0 ports on the back of the iMac.
Got a tech support question? Ask it in the discussion forums.
Want tips like this delivered to your inbox every week? Subscribe to the free weekly iPhone/iPod email newsletter.