The Baptism of John was calling sinners to repentance. It was unusual in that it was treating the Jews as Gentiles. Everyone was considered impure and needing washing at the door-step of the New Covenant:
From wiki we get a clear definition of the Jewish Mikveh. It is correctly stated here that:
Several biblical regulations specify that full immersion in water is required to regain ritual purity after ritually impure incidents have occurred.
It signified washing impurity away.
More applicable to our text Mikveh was used, and is still used today to convert Gentiles to Judaism. Here is a quote from the Jewish historian Alfred Edersheim on the subject:
‘the proselytes of righteousness,’ who became ‘children of the covenant,’ ‘perfect Israelites,’ Israelites in every respect, both as regarded duties and privileges. All writers are agreed that three things were required for the admission of such proselytes: Circumcision (Milah), Baptism (Tebhilah),and a Sacrifice (Qorban, in the case of women: baptism and sacrifice) - the latter consisting of a burnt-offering of a heifer, or of a pair of turtle doves or of young doves (Maimonides, Hilkh. Iss. Biah xiii. 5).
So the question remains why did Jesus submit to a baptism calling everyone to repentance for their sins, in preparation of Christ’s appearing?
There are many views why Jesus was Baptized, some of the better views are; His coming as the Representative of a guilty race, or as the bearer of the sins of others, or of His surrendering Himself symbolically to death for man. However as Jesus came to ‘fulfill all righteousness’ it seems to best to say that He came to perform perfect obedience to Gods Law. This obedience not only included all the ceremonial, civil and moral laws given to Moses, but as Christ was not only God but man, He must also submit to the ministries of Prophets sent by God. Furthermore the level of consciousness that Jesus, as a man, had of His purpose and ministry seems to have taken a sudden increase after His submission. For it is hear that God declares from a voice from heaven and a visible token of His Spirit anointing Him for His ministry that he has the One whom God loved, that is the King Messiah, and also the suffering servant who He was well pleased with.
So His baptism was to fully comply with all Laws in order to have a righteousness that He could provide to sinners while the sins of the world were placed upon Him in return. This is why John says:
The next day John saw Jesus coming toward him and said, "Look, the Lamb of God, who takes away the sin of the world! (NIV John 1:29)
Jesus was presenting Himself as the Lamb in Baptism, to suffer all the sins of men punishable under the Laws of Moses. John was including the righteous Pharisees and sinful tax collectors as equally needing this baptism of repentance for sin. Jesus was the center upon which this baptism had meaning, for water does not cleanse.