Pigeons get a pretty raw deal and their comical head-bobbing probably doesn't help their public image. The reason why they do it has been a topic of debate for quite some time amongst the kinds of people whole like to debate this stuff, and a pretty convincing theory has arisen from it. Contrary to what you might expect, the head-bobbing actually allows the pigeons to stabilise their vision. Different animals have different techniques for this; humans, for example, constantly twitch and readjust their eyes in order to keep everything steady. The bobbing motion has nothing to do with the walking mechanism, but the relative steadiness of their surroundings. In the 70s, some researchers put pigeons on a treadmill (hey, it was the 70s, you could do that kind of thing and call it science) and found that the head bobbing stopped due to the fact that the pigeons surroundings were no longer moving in relation to its eyes. The bobbing motion itself is actually something of an illusion. Frame-by-frame video analysis has shown that the head isn't actually bobbing back and forth, but more "locking" into position whilst the rest of their body catches up, at which point it shoots forwards again and locks. This is a bit like when you fix your gaze on something and move your head around. The poor pigeons might look a bit dorky, but it's just their way of dealing with things. They don't laugh at your twitchy little eyes so give 'em a break.