The building of the ark has a double effect:
condemnation of the world who does not believe the message of salvation;
justification of Noah of the righteousness by faith.
In Genesis 6:8–9 is written that Noah found favour in the eyes of the Lord because he was a righteous man, blameless in his generation. Noah was sincere. But the fact that he was righteous does not mean that he was without sin. After the flood, for example he became drunk (Genesis 9:20–23). He was blameless in his generation, but he was not blameless in the eyes of the Lord. He also needed the righteousness that is blameless for God. And the only righteousness that is blameless in the eyes of the Lord is the righteousness of Jesus. Noah was saved in the ark to live in a new world where Jesus would come and save us by his perfect righteousness for us. Paul says in Philippians 3:8–9 that he wanted to gain Christ and be found in him not having a righteousness of my own that comes from the law, but that which comes through faith in Christ, the righteousness from God that depends on faith.
Noah became an heir of that righteousness.
7 By faith Noah, being warned by God concerning events as yet unseen, in reverent fear constructed an ark for the saving of his household. By this he condemned the world and became an heir of the righteousness that comes by faith.