The analogy illustrates the futility of trying to reach God's standard of holiness on your own. It's an illustration, not a mirror.
You are correct. A person who lives a good life because he wants a divine reward is not doing good things as the result of a changed heart, he is trying to obligate God to reward him. God is not an ATM. See below for the explanation of faith and works.
The law of gravity applies to you whether you want to believe it or not. God's standard also applies to everyone, whether they want to believe it or not.
It's irrelevant whether they have a "good" heart or not, because they don't have a perfect heart. The analogy stands because it illustrates the futility of trying to "earn" God's favor (actually, you're trying to obligate God to bless you, in essence treating Him like an ATM) through works.
Now, you also fail to understand the relationship between faith and works. The Christian doesn't do good works hoping to earn salvation, he does good works because they are the natural result of the change in his heart. When you're in love with a person, you do good things for them, but you don't do those things because you want to obligate them to do things for you, that's cynical manipulation. You do those things because you want that person to be happy. The same with the Christian. His works are the result of, not the hope of, salvation.
I said before that you are correct, someone living a "good" life hoping it will earn him favor from God is on a fool's errand. We cannot obligate God to give us favor through our works.