The self righteousness and injustice of Man was portrayed in the most extreme form when Christ Jesus was arrested, beaten, stripped, spit on, mocked, and nailed to the cross. Christ, Who was holy and knew no sin, was looked upon by Man as a common criminal. Of course the religious leaders conspired against Him and lied concerning His character so they could have a reason to prosecute and sentence Him. All this was the most unjust event that ever happened in history and done out of the most vile, hateful, self righteousness that flows from the heart of Man.
At this same time God the Father was actively engaging Himself in the work of Christ on the cross the whole way through. He had purposed and decreed it before the world began. God through His wisdom designed a salvation that would both magnify His attributes and save sinner's at the same time. He did this by imputing the sin of the Elect to Christ so the God-man could suffer the penalty of that sin, purging it by taking the God's wrath and punishment for sin and satisfying what the law demanded by way of a death payment. Christ Jesus, the God-man mediator, was a holy, spotless sacrifice and was qualified and able to do the work of redemption.
Did God the Father punish Christ unjustly? That would be the furthest thing from the truth. By the imputation and transfer of sin from the Elect to Christ, God JUSTLY bruised, punished, killed, His only begotten Son. If not for God's wisdom in the use of imputation He could not have justly punished Christ. But when He did, it was the one of the most holy and just acts that ever happened. Christ was declared guilty by imputation and then deserved death. Imputation is real, not make believe. It really works. Thank God for it.
So, the most just and unjust thing in all the world happened at the same time nearly 2000 years ago. As a result He is both a just God and a Saviour when He saves the ungodly by a righteousness imputed which was the result of the whole merit of the work of Christ. This God is the only God Who is able to save by grace and stay holy. He can keep His perfect standard and still have mercy. God respects the person of Christ only. There is safety in Him. Trust Him every second and NEVER lean on the arm of the flesh.