Baptism, following repentance (changing our way of life), by immersion in water for the forgiveness of past sins and as the beginning of a new life, was begun by John Baptist and continued by Jesus.
Before John the Jews practised ritual washing but not baptism for the remission of sin as enjoined by John.
John prepared the way for the ministry of Jesus.
Jesus was baptised by John as an example to all those who would believe the gospel.
Matthew 3:15 But Jesus answered and said to him, "Permit it to be so now, for thus it is fitting for us to fulfill all righteousness." Then he allowed Him.
Baptism is validated by believing the gospel.
Mark 16:15 And He said to them, "Go into all the world and preach the gospel to every creature. 16 "He who believes and is baptized will be saved; but he who does not believe will be condemned.
Why Baptism Really Matters: https://www.thisisyourbible.com/library/show/178
I hope you find this helpful.