At some point after Jesus began his public ministry, John the Baptist is imprisoned by Herod Antipas, a son of King Herod, because John had spoken out against Antipas.
While John was in prison, and before he was beheaded, he sends two of his disciples to Jesus to ask if Jesus is the Messiah or if there is someone else who is still to arrive.
John might have been wrestling with doubts as he neared the end of his life, or perhaps he wanted his disciples to see for themselves that Jesus is the Messiah and that they should be following Jesus.
When these two disciples of John find Jesus, they ask him the question. Jesus responds by telling them that they have already witnessed the answer -- they have already heard him preach the Gospel, or good news, to the poor, and they have already seen him perform miracles. These two things are fulfillments of Messianic prophecy, including the prophecies in Isaiah 61:1-2 and Isaiah 35:4-6. Jesus was showing them that he is the promised Messiah.
As explained in the Gospel of Luke:
21 In that hour he cured many of diseases and plagues and evil spirits; and to many who were blind he gave sight. 22 Jesus answered them, “Go and tell John the things which you have seen and heard: that the blind receive their sight, the lame walk, the lepers are cleansed, the deaf hear, the dead are raised up, and the poor have good news preached to them. 23 Blessed is he who finds no occasion for stumbling in me.”
24 When John’s messengers had departed, he began to tell the multitudes about John, “What did you go out into the wilderness to see? A reed shaken by the wind? 25 But what did you go out to see? A man clothed in soft clothing? Behold, those who are gorgeously dressed, and live delicately, are in kings’ courts. 26 But what did you go out to see? A prophet? Yes, I tell you, and much more than a prophet. 27 This is he of whom it is written,
‘Behold, I send my messenger before your face, who will prepare your way before you.’ [Malachi 3:1]
28 “For I tell you, among those who are born of women there is not a greater prophet than John the Baptizer, yet he who is least in God’s Kingdom is greater than he.”
29 When all the people and the tax collectors heard this, they declared God to be just, having been baptized with John’s baptism. 30 But the Pharisees and the lawyers rejected the counsel of God, not being baptized by him themselves.
31 “To what then should I compare the people of this generation? What are they like? 32 They are like children who sit in the marketplace, and call to one another, saying, ‘We piped to you, and you didn’t dance. We mourned, and you didn’t weep.’ 33 For John the Baptizer came neither eating bread nor drinking wine, and you say, ‘He has a demon.’ 34 The Son of Man has come eating and drinking, and you say, ‘Behold, a gluttonous man, and a drunkard; a friend of tax collectors and sinners!’ 35 Wisdom is justified by all her children.” (Luke 7:18-35, WEB)
Read more in the book Jesus the Miracle Worker: The 46 miracles of Jesus explained in chronological order (The Jesus Books) -- now available at amazon.