There is Peace in Understanding
The true reality about grace and our salvation, is that we indeed need to act in righteousness, yet this is only accomplished in the first place, by the means and use of grace. We can do no good thing without Christ through His atonement, even if we don’t acknowledge Him as the source. Grace is a fruit of His atonement.
Judgement applies to all, yet with different backgrounds, there are also different parameters. Those who have the law of Christ, and know and understand the principles of life in Christ and faith, are expected to live so. Those who do not have the law or know Christ, will eventually be presented with the gospel at some point or another, either in this life or the next. They will then be judged fairly with what they did know and have, according to their time as man or woman in the flesh.
We will all have fair opportunity to act in accordance to the law, with our understanding of it. All will eventually be given the opportunity to accept the gospel and required ordinances therein, such as baptism, confirmation, and the other priesthood ordinances, including a marriage sealed for all eternity.
These will be made available for everyone who so chooses. Those who never had the opportunity to acquire these saving ordinances for themselves in this life, will have them done by someone else through proxy, usually through a descendant of the person, who takes their genealogical information to the Houses of the Lord, known as Holy Temples, to do their work. For example, I could be baptized in the Temple for a great grandfather of mine, who was never a member of Christ’s church, but was taught the gospel in the after life, and can now accept the baptismal ordinance I performed through proxy.
This method of proxy on behalf of someone else is not new to Christianity, for even the atonement itself is an act of proxy, wherein the Lord took our sins for us, and gave us His life and salvation in return.