'God justifies the ungodly.' (Romans 4:5)
Simple as that. We are ungodly, and our distinct condition (sin) keeps God from having anything to do with us. Yet he declares that we are righteous because of what Jesus Christ has done for us and in us. The work of Christ is applied to us when we believe in him alone for our salvation.