The Righteousness of Christ Imputed In the Old Testament
The sacrificial system of animal sacrifices was called into existence, which for four thousand years pointed to the great sacrifice offered on Calvary for us.
So by offering sacrificial lambs it showed faith in the future Sacrifice that would take place on Calvary. This is why Cain's offering of fruit was rejected because it didn't show faith in the future Sacrifice and righteousness could not be imputed to him because righteousness is imputed only by faith.
Abel's sacrifice was accepted because he brought a lamb which showed his faith in the future Sacrifice that would be accomplished on Calvary for him. Therefore Christ's ETERNAL RIGHTEOUSNESS modeled in thirty three and a half years of perfect obedience that would be accomplished in the future for him could be INSTANTLY imputed to him.
It is the same righteousness that Jesus possessed from all eternity. The law of God, which is the standard of perfect righteousness, man transgressed.
In order to save him from the penalty of transgression, One who has righteousness equal with the law must now wrap Himself in dust by becoming the second Adam and maintain that righteousness that He possessed from ALL eternity as a man, so He can legally impute it to mankind.
This is why the incarnation had to take place. Divinity needed humanity to maintain righteousness as a man and then impute it to all who believe. That's also why the sacrificial animals had to be spotless and blemish free because it pointed for four thousand years to the spotless life and sacrifice that our Lord accomplished for us on Calvary!