When Jesus was baptized by John the Baptist, it was to fulfil all righteousness. This act demonstrated Jesus' obedience to God's will and his identification with humanity. Though Jesus was sinless, he participated in the baptism to align with God's plan and set an example for others. This event is recorded in the Gospel accounts, including Matthew 3:13-17.