The Bible says:
13Then Jesus came from Galilee to the Jordan to John, to be baptized by him. 14John would have prevented him, saying, “I need to be baptized by you, and do you come to me?” 15But Jesus answered him, “Let it be so now; for thus it is fitting for us to fulfil all righteousness.” (Matthew 3:13-15)
29The next day he saw Jesus coming toward him, and said, “Behold, the Lamb of God, who takes away the sin of the world! 30This is he of whom I said, After me comes a man who ranks before me, for he was before me.' 31I myself did not know him; but for this I came baptizing with water, that he might be revealed to Israel." 32And John bore witness, "I saw the Spirit descend as a dove from heaven, and it remained on him. 33I myself did not know him; but he who sent me to baptize with water said to me, He on whom you see the Spirit descend and remain, this is he who baptizes with the Holy Spirit.’ 34And I have seen and have borne witness that this is the Son of God.” (John 1:29-34)
From The Compendium of the Catechism of the Catholic Church (CCC):
105. Why did Jesus receive from John the “baptism of repentance for the forgiveness of sins” (Luke 3:3)?
To inaugurate his public life and to anticipate the “Baptism” of his death, he who was without sin accepted to be numbered among sinners. He was “the Lamb of God, who takes away the sin of the world” (John 1:29). The Father proclaimed him to be his “beloved Son” (Matthew 3:17) and the Spirit descended upon him. The baptism of Jesus is a prefiguring of our baptism. See CCC 535-537, 565.