This is the basis for us to be able to be declared righteous:
Romans 5:6 For, indeed, while we were still weak, Christ died for ungodly men at the appointed time. 7 For hardly would anyone die for a righteous man; though perhaps for a good man someone may dare to die. 8 But God recommends his own love to us in that, while we were yet sinners, Christ died for us. 9 Much more, then, since we have now been declared righteous by his blood, will we be saved through him from wrath. 10 For if when we were enemies we became reconciled to God through the death of his Son, how much more we will be saved by his life, now that we have become reconciled. 11 Not only that, but we are also rejoicing in God through our Lord Jesus Christ, through whom we have now received the reconciliation.