Atheist here, but I will take a crack at it: he said this knowing that it was impossible.
If you ask me how you can stop your wife divorcing you and I say "just go back in time and don't cheat on her", I'm conveying the point Jesus was: you can't.
The righteousness he refers to is only conferred righteousness, by virtue of having been saved.
This is a specious position that seems to be held by many Christians. The first concept is "The total depravity of man". This concept is completely alien to the gospel preached by Jesus. As is the second concept of "imputed righteousness". While preaching His gospel, Jesus spoke of neither. If you believe that He did, then cite the passages. The fact is that He repeatedly pointed in the opposite direction.
It also doesn't hold water if one takes a holistic view of the gospel preached by Jesus. For example:
John 8
"34Jesus answered them, “Truly, truly, I say to you, everyone who commits sin is the slave of sin."
" 31 ...If you abide in My word, then you are truly disciples of Mine; 32and you will know the truth, and the truth will make you free.”
"36So if the Son makes you free, you will be free indeed. "
" 35The slave does not remain in the house forever; the son does remain forever.
51Truly, truly, I say to you, if anyone keeps My word he will never see death.”
Once again, it is only the truly righteous - that is those who do not commit sin - who are His "true disciples". That will "remain in the house forever". That will "never see death". There's plenty more besides.
He said what he said to stress that he was the only way.
(He also said "Why do you call me good? There is none good, but God".)
More arguments held by many Christians that are dubious if not specious. Taken out of context or otherwise misunderstood. They read so much into so little. Did you get ahold of their playbook? "Perfect" doesn't mean perfect. "Righteous" doesn't mean righteous. ""Repentance" doesn't mean repentance. The list goes on and on. Their position is laughably weak. There's more than a little bit of "motivated reasoning" going on there.
If you're really interested in understanding this topic, I can lay it all out for you. However, my experience on CARM has been that the vast majority of posters aren't really interested. They just want to participate in a bit of superficial jousting.