We cannot earn righteousness, but rather we must receive it as a gift. If we are still trying to earn or work for it, then we are still little babies in Christ:
"13For every one that useth milk is unskilful in the word of righteousness: for he is a babe. 14But strong meat belongeth to them that are of full age, even those who by reason of use have their senses exercised to discern both good and evil." (Hebrews 5:13-14)
Righteousness is all about faith, faith in God's promises specifically, and faith in Christ Jesus essentially:
"And he believed in the LORD; and he counted it to him for righteousness." (Genesis 15:6)
Righteousness is something God declares that He will establish us in:
"14In righteousness shalt thou be established: thou shalt be far from oppression; for thou shalt not fear: and from terror; for it shall not come near thee." (Isaiah 54:14)
"No weapon that is formed against thee shall prosper; and every tongue that shall rise against thee in judgment thou shalt condemn. This is the heritage of the servants of the LORD, and their righteousness is of me, saith the LORD." (Isaiah 54:17)
So, God's gift of righteousness is granted to us as a gift.