"Noah was a just man and perfect in his generations, and Noah walked with God." (Genesis 6:9)
The original text gives the reason why Noah was a "just man and perfect".
But before tackling the reason, it is important to explore the full meaning of who Noah was:
"Noah" means "Rest", he typified a man of repose, one who rested in the Lord, rather than working for Him.
He was a "just man" — yet the text reads צַדִּ֛יק tzaddik, which means "righteous". He was more than ethical or upright (like Job, who suffered great loss), but before God he was acceptable in every way.
He was perfect, which renders תָּמִ֥ים tamim, meaning blameless, without fault. He was a man to whom God imputed no sin.
How was Noah able to be a righteous man without fault in the midst of a generation in which
"the wickedness of man was great on the earth, and that every intent of the thoughts of his heart was only evil continually" (Genesis 6:5)?
The original text provides the answer:
"Noah walked with God."
Here, "walked" translates the word "הָלַך halak", which speaks not just to moving around, but living one's life in accordance with something, or Someone.
Noah wanted to be where God was; he honored God in everything that he did, respecting that He did everything as a result of resting in God.
Therefore, Noah's walk, a walk of faith, made him righteous, as the Patriarch Abraham would be righteous for believing on the Lord (cf Genesis 15:6).