This question is often hotly debated. What is the purpose of baptism; is it for salvation? And if not, then what is it for and why is it important?
I am going to argue emphatically that baptism does not save a person. As the reformers fought so hard to assert, “justification is by faith alone”...
For by grace you have been saved through faith. And this is not your own doing; it is the gift of God, not a result of works, so that no one may boast. (Ephesians 2:8-9)
When the Bible says that salvation is “not a result of works”, that doesn't mean that works are not a result of salvation. Works are associated with salvation, but salvation is not a result of works. This is something that the Bible makes very clear. In Galatians, Paul writes:
For if a law had been given that could give life, then righteousness would indeed be by the law. (Galatians 3:21)
That is to say, if a commandment like “be baptized” could give life (eternal life; salvation), then the implication of what Paul is saying here is that Christ would not have needed to die for us! Paul is arguing fervently against what we call “works righteousness”; that our works will make us righteous enough for God to accept us into heaven. In Paul's context he is talking about things like circumcision, and says:
Look: I, Paul, say to you that if you accept circumcision, Christ will be of no advantage to you. ... For in Christ Jesus neither circumcision nor uncircumcision counts for anything, but only faith working through love. (Galatians 5:2-6)
Again we see it clearly stated that faith is what counts, not rituals like circumcision. And this can be equally applied to baptism. If we can be saved by baptism, then there is no longer one means of salvation (namely faith in Christ). Consider that since the Bible teaches that no law could save us, and that in Acts 4:12 it says that “there is no other name (than Christ) under heaven by which we must be saved”, then the means of salvation must be the same for all of mankind, for all of history, including the Old Testament saints. But the Old Testament saints were not commanded to be baptised for their salvation. How were Old Testament saints saved? By faith, just as we are. Faith is the means of salvation in the Bible and not works, or even “faith plus works”. Paul, proving that faith is the basis for our justification, uses the illustration of Abraham's faith (Romans 4:3), and elsewhere quotes Habakkuk 2:4 - “The righteous shall live by faith.” If the Old Testament saints were saved by faith alone, though they had such a vast number of cultic rituals, why would Christ add a requirement of works for us now?
So where do people get confused? Why do people think that baptism is necessary for salvation? It seems to be because of verses like Mark 16:16:
Whoever believes and is baptized will be saved, but whoever does not believe will be condemned. (Mark 16:16)
This verse seems to undo the whole argument; it seems explicit that baptism (plus faith) is necessary for salvation. But let's consider another passage of the New Testament...
if you confess with your mouth that Jesus is Lord and believe in your heart that God raised him from the dead, you will be saved. (Romans 10:9)
Is saying the words “Jesus is Lord” out loud another requirement for salvation? Jesus said “For out of the abundance of the heart the mouth speaks.” (Matthew 12:34). This verse in Romans 10 is speaking of the external sign of what's already in one's heart. It speaks of something that is so closely linked with faith that it stands for faith. If you have faith, you will make a public confession that Jesus is Lord. Well, baptism is precisely the same thing. In those days, in that culture, baptism was automatically the first thing someone did when they converted to a new religion. It stood for a public declaration that one was now a part of that religion. Baptism is a public identification with Christ and His Church, and it communicates our spiritual death and resurrection in Christ. It's this public declaration that is the main issue. Just as merely saying the words “Jesus is Lord” doesn't save you, neither does the mere act of baptism. Both need to be an outward expression of what is genuinely in one's heart.
Can one be saved and never tell anyone that they're a Christian, whether verbally or through the display of baptism? Perhaps there are some hard cases in places of extreme persecution, or we can contrive an example of a man alone on a desert island; but we have these words of Christ:
So everyone who acknowledges me before men, I also will acknowledge before my Father who is in heaven, but whoever denies me before men, I also will deny before my Father who is in heaven. (Matthew 10:32-33)
Is confession of faith a “work” that results in salvation? No, as we read in Matthew 12:34, it is a result of what's in our heart, and a new heart is the result of salvation...
And I will give you a new heart, and a new spirit I will put within you. And I will remove the heart of stone from your flesh and give you a heart of flesh. (Ezekiel 36:26)
So we see that often the Bible will speak of the confession of faith as though it were faith, and baptism (being a confession of faith) likewise, because these are the visible sign of faith. Or if we read James carefully, (though he's not the only one to say it), all manner of good works should be the result of faith.
Since we have the same spirit of faith according to what has been written, “I believed, and so I spoke”, we also believe, and so we also speak (2 Corinthians 4:13)