All that God does, he does according to law. Today's legal system is based upon God's law. If you commit a crime you will find yourself in a court of law and will be judged according to the law. There are legal words in the Bible like "Justification" and "Condemnation". No one will enter heaven that has not been legally justified by Jesus Christ. There is only one way to be legally justified. Those that are legally saved are justified by Jesus Christ. Trying to be saved through predestination (Calvinism) or an infused righteousness (Catholicism) are illegal and not according to God's way or his law.
If God declared that you are saved it would have to be on the merit of Jesus Christ and not on the Merit of your own works or righteousness. We all stand before God's court as guilty. This is why Paul wrote, "There is none righteous, no, not one" Romans 3:10. We all need to be justified since we are all helpless sinners, justification must come to us outside of ourselves. It has in the person of Jesus Christ.
"But to him that does no works, but believes on him that JUSTIFIES the UNGODLY (guilty sinners) his faith (not his works or obedience) is counted for righteousness" Romans 4:5. In God's court faith in Jesus Christ counts for righteousness. Because of the doing and the dying of Jesus we can now stand before God's court as justified. The righteousness of Christ is imputed to us and we are justified based upon his merit and his merit alone.
"To declare, I say, at this time HIS righteousness: that he might be just and the justifier of him which believes in Jesus" Romans 3:26.
The righteousness of another (Jesus Christ) is what saves us. Not a declaration from God that you have been predestinated. Not an infused righteousness that the Bible knows nothing about. Justified by Christ and by Christ alone.
Because of the doing and the dying of Jesus salvation and justification have been provided by Jesus for the whole world, 1 John 2:2, 1 John 4:14, Hebrews 2:9, plus many other scriptures.
"By the righteousness of one (Jesus Christ) THE FREE GIFT came upon ALL MEN unto justification of life" Romans 5:18.
"Came upon all men" means that it is available to all men. God has provided salvation and justification for everyone. It is offered to all of humanity as a free gift from God, Ephesians 2:8. There is no reason for any one to be lost. If Jesus has fulfilled all of the demands of God's holy law and has atoned for the sins of the whole world, then that means all, anyone, everyone, whosoever that shall call upon the name of the Lord can be saved, Romans 10:13.
Just as God imputes righteousness and justification to the saved. He imputes sin and condemnation to the unsaved. In the judgment all that are not found to be justified by Christ and stand before God's court as righteous, will have their sins imputed back to them and will be condemned. "Blessed is the man to whom the Lord will not impute sin" Romans 4:8. Even though the sins of the world have been atoned for. God can still and will impute sin back to the unbeliever and condemn them to hell.
This is why Paul wrote, "That I might be found in him, not having my own righteousness, which is of the law, but that which is of the faith of Christ, the righteousness which is of God by faith" Philippians 3:9.
Faith brings righteousness, not works, obedience or religion.