So after it's all said and done and the dust has settled, we will be brought to stand before God. The prophet Alma teaches, "..The atonement bringeth to pass the resurrection of the dead; and the resurrection of the dead bringeth back men into the presence of God; and thus they are restored into his presence, to be judged according to their works..." (Alma 42:23) Now it is vital to understand here that the Atonement purifies us at least temporarily so we may be judged in His presence for the simple reason that Isaiah says so plainly, "But we are all as an unclean thing, and all our righteousnesses are as filthy rags; and we all do fade as a leaf; and our iniquities, like the wind, have taken us away." (Isaiah 64:6) Also as Nephi states, "..No unclean thing can dwell with God..."
The Resurrection of the dead is a free gift of the Savior to all those who accepted His plan in the Pre-Earth Life. To explain a little more of what exactly the resurrection is, the prophet Alma teaches, "The soul shall be restored to the body, and the body to the soul; yea, and every limb and joint shall be restored to its body; yea, even a hair of the head shall not be lost; but all things shall be restored to their proper and perfect frame." This resurrection is to happen to ALL people regardless of how you lived your life on Earth, however this is not Salvation, which is Eternal Life. Eternal Life comes from the judgment of God.
The prophet Alma testified, “Our words will condemn us, yea, all our works will condemn us; … and our thoughts will also condemn us” (Alma 12:14) John the Revelator says, "And I saw the dead, small and great, stand before God; and the books were opened: and another book was opened, which is the book of life: and the dead were judged out of those things which were written in the books, according to their works" (Revelation 20:12) Clearly the final Judgment has a direct correlation to the actions we have done here in this life. This is why the Savior warned so fervently that we need to strive to, "Be ye therefore perfect, even as your Father which is in heaven is perfect." (Matthew 5:48 ) Through accepting Jesus Christ and repenting of your sins and in following His footsteps through baptism and through the reception of the Holy Ghost we may be found clean at His judgment bar.