The Bible clearly teaches that salvation cannot be earned. It is a gift from God, received through faith (Ephesians 2:8–9). We are told that we must be perfect like God (Matthew 5:48), and thus trying to earn it is an all-or-nothing proposition (Galatians 3:10; James 2:10). Either we are perfect, or our works will not save us. Jesus came because we cannot pay the debt we owe (Colossians 2:13–14). He came to die in the place of sinners (1 Peter 3:18) and is the only way to be saved (John 14:6).
That said, it is possible for a new believer with an immature knowledge of Scripture to inconsistently think that they maintain their salvation through obedience (Galatians 4:9–11). Because salvation only requires childlike faith (Matthew 18:3), which implies doctrinal imprecision, some freedom must be given to a new believer who might be mistaken in this area.
However, one cannot actively and persistently insist that salvation can be earned and still be a genuine believer (see Galatians 5:4). Such a statement demonstrates a lack of understanding of why Jesus needed to die for sin.
Salvation is a gift from God (Ephesians 2:8–9). Being a gift means it cannot be earned. In fact, Paul notes that sin, not salvation, is what we earn (Romans 6:23a). Every religion except for Christianity is based on the belief that salvation can be earned. Even the “nones,” those who claim to have no religious affiliation, still view their good works in a favorable light. This is because people misunderstand sin and salvation.
Sin is doing anything contrary to what God commands. Another word for that is rebellion. Every sinful act we commit is us, as creatures, thumbing our noses at God, our Creator. Rebellion requires punishment. Our works, good or otherwise, do not affect that. Consider a bank robber, for example. When caught, he cannot plead his case by saying he is a good person or by doing nice things. Regardless of what he says or does, he has still robbed a bank and must be punished for that crime.
Likewise, it does not matter whether we are charitable, kind to others, or do a bunch of religious activities. We still have the crime of rebellion hanging over us, and God must punish us for that crime. True justice does not allow someone to buy themselves out of judgment, and since God is perfectly just, He is not appeased by what we do.
However, out of mercy, He sent His Son, Jesus. He placed the sins of repentant men and women on Jesus and then poured out the full punishment they deserved on Him. Salvation is receiving Jesus’ substitutionary death by repenting of sin and trusting that Jesus has already paid the penalty. That is the only way one can be saved.