Even John the Baptist had doubts about whether Jesus was really the promised Messiah. [source][source][source]
"Matthew includes the record of this interrogation for at least two reasons. First, the questioning of Jesus by John , a representative of the best in Israel, points up the misconception of Israel as to the program of the Messiah and His method. He had heard of the works of Jesus ( Matthew 11:2), and they certainly appeared to be Messianic. However, Jesus did not suddenly assert His authority and judge the people as John probably had thought He would ( Matthew 3:10-12). Because of this misconception he began to doubt. Perhaps his being in prison, a place which was certainly incongruous for the herald of the King, reinforced his doubts.... [source][source][source]
"The second purpose of these few verses ( Matthew 11:2-6) is to reaffirm the concept that the works of Jesus prove His Messiahship." [1][source]