I think there are three general reasons:
1. To signal the new covenant beginning. The kingdom of God was "at hand," and just as Joshua led the people of God across the Jordan to the Promised Land, the true and better Joshua leads his people at the Jordan River in baptism, signaling the fulfillment of the Promised Land shadow.
2. "To fulfill all righteousness" (Matthew 3:15). Jesus was baptized because he was obedient to God's commands, including the prescribed rites for entrance into the priesthood (Leviticus 8:6; Exodus 29:4). To be our great high priest after the order of Melchizedek, he needed the ritual washing. If he hadn't submitted to baptism he would have had a sin to repent of in baptism! Instead, Jesus is baptized as part of his total life of obedience to the Father's will. We need a perfect righteousness to be saved, and Jesus gives us his, which includes his baptism:
3. To be our substitute. When we are baptized we are making our profession of faith in Christ, making an appeal to God based on what baptism corresponds to (1 Peter 3:21). But we still come up out of the water as sinners. Our baptism is made perfect, however, because through faith, Christ's baptism becomes our baptism (Romans 6:3-4; Galatians 3:27). It is part of his eternal obedience imputed to us.