From one perspective our good deeds have absolutely nothing to do with our salvation; from another perspective they have everything to do with it. This is the core debate that has been raging among Christians ever since the Protestant Reformation.
I am persuaded that our good deeds never merit salvation. To merit salvation would mean to earn it or to deserve it. The deeds would have to be so good, so perfect, with no mixture of sin in them, that it would impose an obligation upon God to grant us salvation. I believe that the New Testament is abundantly clear that none of us lives a life that is good enough to earn salvation. We receive God's salvation while we are sinners (Eph. 2:1-6). That's why we need a Savior, an atonement—and why we need grace.
People often say, "Nobody's perfect." We all agree on that. But not one person in a thousand realizes how significant that statement is. Somehow they think that God is going to grade on a curve and "as long as my life is less sinful than somebody else's, then relatively speaking it's good enough to make it into God's kingdom." We forget that God requires perfect obedience to his law, and if we fail to obey him perfectly, then we're going to have to look elsewhere for a way to get our salvation. That's where Christ comes in. Christ makes his merit available to us. When I trust him by faith, then his righteousness becomes my righteousness in the sight of God. So it's his good work that saves me and that saves you—not our good works.
Nevertheless, in a response of gratitude we are called to obey. Jesus said, "If you love me, keep my commandments." Martin Luther taught that justification is by faith alone. But he expanded the concept by saying that justification is by faith alone, but not by a faith that is alone. A person who is truly trusting Christ and resting on Christ for redemption receives the benefits of Christ's merit by faith. But if that person has true faith, that true faith will manifest itself in a life of obedience. Simply put, I get into heaven by Jesus' righteousness, but my reward in heaven will be distributed according to my obedience or the lack of it.