It is somewhat similar in our lives. We can do a thousand good things, but if we don't know God it doesn't matter. If we die before we know Him, there's only one place to go, no matter how "good" we were. Maybe you think that's unfair. That all our good deeds should count towards something. And I'm not saying not to do anything good anymore. I'm saying that if He's not our God and we're not His child, it's not going to save us. Only one thing can.
There is only one way to get to heaven and to be with God. That's His Son. Only God can save us. Only Christ's death and cleanse away our sins.
"Jesus answered, “I am the way and the truth and the life. No one comes to the Father except through me." John 14:6 (NIV)
"Whatever you do, work at it with all your heart, as working for the Lord, not for human masters, since you know that you will receive an inheritance from the Lord as a reward. It is the Lord Christ you are serving." Colossians 3:23-24 (NIV)
But that reward is something so small compared to actually being with God forever and ever. And we get that by mercy and grace.
"For it is by grace you have been saved, through faith—and this is not from yourselves, it is the gift of God— not by works, so that no one can boast." Ephesians 2:8-9(NIV)
In the end, only one thing decides if we'll spend eternity with the Creator or not.
Yes, it isn't fair. It is mercy.