Up to yesterday, the answer that I would have given to that question was: to show us how to live properly with one another -to be our greatest example. I would have wheeled out verses like Matthew 16:24 to make my point good. That, whilst not a wrong answer, is not the best answer. There is a better one.
To help us we need to consider Hebrews 2:10 and what it means that Jesus was made perfect through suffering.
The simple answer is that over his "planet-earth" lifetime he was in himself crafting the righteousness that he would give to all people, whether Old or New Testament, whether Jew or non-Jew, who put their trust in him.
Like the prototype wing being taken to the wind tunnel to test its integrity, so Jesus was sent to earth to test (although probably vindicate is a better word here) his righteousness and win himself a people to be his very own.
So the righteousness that Jesus gives his people is not a "bargain-bucket" righteousness that breaks on first use, untried and untested. It is not a righteousness that has never experienced demonic attack or fear or suffering or limitation or abandonment, or temptation to self exultation; it is a tried and tested righteousness that is strong: approved by God the Father and attested by God the Holy Spirit.
So if like me, you have put your trust in him in this earthly life, then when we stand before Jesus in the Judgment and he considers us, he will see neither our lifetime lack of righteousness nor our heap of wickednesses, but rather his own lifetime of tried and tested sinless perfection radiating back at him. He will then say This one I know, for I see my likeness (righteousness) in him. Welcome good and faithful servant, come and share in my Father's happiness, then he will introduce and commend us to the Father.
What a moment that will be.
What an awesome God!