To have our sins forgiven we need to associate ourselves with the death and resurrection of Jesus. The mechanism that God has provided for this is baptism.
Baptism is the burial of a believer in water as a symbol of the death of Jesus, and is described exactly like this in Paul’s letter to the Romans.
"Do you not know that all of us who have been baptized into Christ Jesus were baptized into his death? We were buried therefore with him by baptism into death, in order that, just as Christ was raised from the dead by the glory of the Father, we too might walk in newness of life." (Romans 6:3,4)
The picture of baptism here emphasises the idea that baptism involves submerging the person being baptized in water so that they are completely immersed in it. They then come back up from the water, symbolising the resurrection of Jesus. This baptism is conducted to associate the candidate with the death and resurrection of Jesus. This is the time at which we become associated with Jesus.
"For if we have been united with him in a death like his, we shall certainly be united with him in a resurrection like his."
The idea here is that by being associated with the death of Jesus in baptism we are then to be raised in a resurrection like that of Jesus. This, however, is at the day of judgement.
A further picture of the symbolism of baptism appears in the next verses.
"We know that our old self was crucified with him in order that the body of sin might be brought to nothing, so that we would no longer be enslaved to sin. For one who has died has been set free from sin." (Romans 6:6,7)
This depicts baptism as the point at which we are set free from the grasp of sin. The picture is of sin as a master who holds sinners as slaves. By being baptized we are no longer the slaves of sin. The point of this is that sin leads to death. By being set free from sin we are also set free from this law; sin will no longer lead to our complete death. Instead death becomes a sleep which ends in an awakening at the day of judgement.
"Now if we have died with Christ, we believe that we will also live with him. We know that Christ, being raised from the dead, will never die again; death no longer has dominion over him." (Romans 6:8,9)
The point is that by being associated with the death of Jesus we follow him to eternal life. To die with Christ in baptism is to live with him in the resurrection.
One can summarise the Biblical picture of baptism as:-
Baptism is the burial of a believer in water.
It brings the association of the believer with the sacrifice of Jesus Christ.
It is the first action of a life of faith.
By being baptized, one sets one’s feet on the way to salvation. This requires a conscious choice; one must decide to follow Christ Jesus in order to be baptized. The decision to follow Christ Jesus and live a life of faith is called “repentance”. This is the decision that precedes baptism. It is spoken of by the Apostles:
"Now when they heard this they were cut to the heart, and said to Peter and the rest of the apostles, 'Brothers, what shall we do?' And Peter said to them, 'Repent and be baptized every one of you in the name of Jesus Christ for the forgiveness of your sins, and you will receive the gift of the Holy Spirit. For the promise is for you and for your children and for all who are far off, everyone whom the Lord our God calls to himself.'” (Acts 2:37-39)
The people who heard the Apostle Peter asked him what they should do to follow the risen Jesus. His answer was that they should repent - choose to follow God’s way - and be baptized. This is what we also need to do.
Of course, baptism is only of use if it is an action which stems from faith.