John says in his first letter, in verses 7 and 8, "For there are three that testify: the Spirit and the water and the blood; and the three are in agreement."
It is obvious that we are saved by the blood of Jesus Christ, in that our sins are fully payed for by the act of His death, and there no longer stands any accusation or record of wrong against us (Colossians 2:14, Romans 8:1). The [Holy] Spirit is given to us as a seal of our salvation, and a placeholder--a promise of our inheritance (Ephesians 1:13-14).
Peter explains how the water contributes to testify to our salvation in 1 Peter 3:19-22
After being made alive, he went and made proclamation to the imprisoned spirits—to those who were disobedient long ago when God waited patiently in the days of Noah while the ark was being built. In it only a few people, eight in all, were saved through water, and this water symbolizes* baptism that now saves you also—not the removal of dirt from the body but the pledge of a clear conscience toward God. It saves you by the resurrection of Jesus Christ, who has gone into heaven and is at God’s right hand—with angels, authorities and powers in submission to him.
The Greek word translated "symbolizes" in the NIV means "antitype". It is my opinion that our action of baptism is being compared here to Noah's building of the ark, and "this water" is a proper antitype of the water of baptism--in that the flood water was God's wrath poured out on the wickedness around Noah while he was hidden from it inside the ark, but in baptism, we follow Christ into the water of mercy, and passing through it, we are cleansed.
In short, baptism is the action by which we exercise faith to be saved, just as Noah did when he built the ark. Faith is the key.
If Noah heard from God and believed, but did not construct the ark in the manner prescribed, he would have died like everyone else. God also could have saved Noah without any work on Noah's part at all--in fact, He could have done it without even telling him. By God's design, just as we are condemned by our disobedience, we must submit in obedience to obtain redemption.
Or don’t you know that all of us who were baptized into Christ Jesus were baptized into his death? We were therefore buried with him through baptism into death in order that, just as Christ was raised from the dead through the glory of the Father, we too may live a new life. For if we have been united with him in a death like his, we will certainly also be united with him in a resurrection like his. (Romans 6:3-5)
and in Him you were also circumcised with a circumcision made without hands, in the removal of the body of the flesh by the circumcision of Christ; having been buried with Him in baptism, in which you were also raised up with Him through faith in the working of God, who raised Him from the dead. (Colossians 2:11-12)
Here Paul directly ties our act of obedience in baptism to Jesus obedience in death and subsequent resurrection and compares it to a spiritual circumcision, which was the act of obedience that God prescribed to Abraham and his descendents as a seal of their faith and share in the covenant.