One school of thought says that John was trying to convince his disciples that Jesus was the Messiah; he believed, but they did not.
John uses this as a teaching technique to detach his disciples from him and attach them to Christ, according to St. John Chrysostom (Homily 36 on Matthew, Matthew 11, 1-3. St. Ambrose of Milan however thinks that John doubted. St. Thomas Aquinas has an interesting commentary on the question:
It was not through ignorance that John the Baptist inquired of Christ's advent in the flesh, since he had clearly professed his belief therein, saying:
"I saw, and I gave testimony, that this is the Son of God"
John 1:34
Hence he did not say: "Art Thou He that hast come?" but "Art Thou He that art to come?" thus saying about the future, not about the past. Likewise it is not to be believed that he was ignorant of Christ's future Passion, for he had already said:
"Behold the Lamb of God, behold Him who taketh away the sins [Vulg.: 'sin'] of the world,"
John 1:39
thus foretelling His future immolation; and since other prophets had foretold it, as may be seen especially in Isaias 53. We may therefore say with Gregory (Hom. xxvi in Evang.) that he asked this question, being in ignorance as to whether Christ would descend into hell in His own Person. But he did not ignore the fact that the power of Christ's Passion would be extended to those who were detained in Limbo, according to Zechariah 9:11:
"Thou also, by the blood of Thy testament hast sent forth Thy prisoners out of the pit, wherein there is no water";
nor was he bound to believe explicitly, before its fulfilment, that Christ was to descend thither Himself.
It may also be replied that, as Ambrose observes in his commentary on Luke 7:19, he made this inquiry, not from doubt or ignorance but from devotion: or again, with Chrysostom (Homily xxxvi in Matthew), that he inquired, not as though ignorant himself, but because he wished his disciples to be satisfied on that point, through Christ: hence the latter framed His answer so as to instruct the disciples, by pointing to the signs of His works.
Personally, I like St. John Chrysostom's explanation.