Baptism by John the Baptist came before the baptism of Jesus because it was the herald’s baptism, anticipating Jesus Christ. It was the purpose of Jesus Christ to have His herald baptize Him. This began His public ministry.
In John’s baptism, the water represented the Kingdom of God, which is the general term for regenerate people from the time of Adam to the end of the Millennium. In the baptism of Jesus, the water represented the will of the Father in salvation - the Cross. This was a unique baptism. The Kingdom of God here is in the form of the King, Jesus Christ. Matt. 3:13-17.
“Then Jesus arrived from Galilee at the Jordan coming to John, to be baptized by him. But John tried to prevent Him, saying, “I have need to be baptized by You, and do You come to me?” But Jesus answering said to him, “Permit it at this time; for in this way it is fitting for us to fulfill all righteousness.” Then he permitted Him. After being baptized, Jesus came up immediately from the water; and behold, the heavens were opened, and he saw the Spirit of God descending as a dove and lighting on Him, and behold, a voice out of the heavens said, “This is My beloved Son, in whom I am well-pleased.”“ (Matthew 3:13-17, NASB)
The will of God must be exercised by regenerate people before the eternal Kingdom of God can be a reality. The Cross must come before the crown! As He went into the water He said in effect, “I will die for the sins of the world.” As He came out of the water, He said in effect, “I will rise again that believers might have resurrection bodies.”
The baptism of Jesus Christ was the counterpart ritual to the reality of the Baptism of the Cup (the Cross). The baptism of Jesus was unique because Christ is unique, and it represents His unique work on the Cross.
He was baptized at the age of 30 at the beginning of His public ministry. The Holy Spirit appeared at His baptism to guarantee that He would sustain Jesus during His ministry. No one ever follows the Lord in baptism. We are not the God-man. We cannot go to the Cross.