1 Peter 3:21 "The figure whereunto [even] baptism doth also now save.us (not putting away the filth of the flesh, but the answer of a good conscience toward God,) by the resurrection of Jesus Christ,"
Peter is teaching that 8 people were in the ark and went through the judgment unharmed, it is comparable to the Christian's experience of salvation being in Christ, the ark of one's salvation.
Baptism... By the resurrection of Jesus Christ," Peter is not teaching water baptism, but he is teaching a figurative into a union with Christ as an ark of safety from God's judgment. Christ's resurrection demonstrates God's acceptance of Christ's substitutionary death for the sins of those who believe ( Acts 2:30-31; Romans 1:4).
"Baptism doth also now save us": does not mean water baptism is essential to salvation. It can't wash away the "filth of the flesh," Baptism is a testimony of one's faith in the resurrection because it symbolizes our resurrection with Him.
To be sure nobody misunderstands him; Peter clearly says he is not talking about water baptism when he says " Not putting away the filth of the flesh."
Water baptism is the outward show of the death of the body and rising from the water into a new life with Christ our redeemer. The real baptism that will save us is the changing of the heart.