At that time Jesus came from Nazareth in Galilee and was baptized by John in the Jordan. Just as Jesus was coming up out of the water, he saw heaven being torn open and the Spirit descending on him like a dove. And a voice came from heaven: “You are my Son, whom I love; with you I am well pleased.” Mark1:9-11 NIV
Why was Jesus baptized? He had no need to repent, as He was sinless. Jesus tells John the Baptist in Matthew 3:15 “Let it be so now; it is proper for us to do this to fulfill all righteousness.” Jesus was baptized to show those who wished to be associated with Him that righteousness required a change of heart from earthly ways, which conflict with that which is required by God. Jesus set an example for all of us of a ceremony associated with the working toward righteousness. One needed a cleansing in water to accompany the repentant heart of the person.
Imagine all the questioning there would be if some were to say that Jesus did not participate in baptism which is required as an outward showing of an inward change in the heart. Jesus certainly eliminated the opportunity for anyone to say that He did not participate in that which is the showing of an inner change.
Jesus did much to set an example for us. For us to be Godly, we need an example. Jesus was the perfect example, as He is the Son of God. Follow in the footsteps of Christ. Do as He did in His walk on this earth.