How strange indeed that Solomon writes about a righteous man perishing in his righteousness.
Later he writes that there is not one man on the earth who walks in righteousness:
"20For there is not a just man upon earth, that doeth good, and sinneth not." (Ecclesiastes 7:20).
Now, Solomon wrote these sobering words at the end of his life, long before God sent His Son to be our Savior.
But Jesus fit the profile of the man whom Solomon longed for but could not find.
He was the righteous man who died in His righteousness--to give it to all of us!
"For he hath made him to be sin for us, who knew no sin; that we might be made the righteousness of God in him." (2 Corinthians 5:21)
Now, we as sons of Adam were all wicked, dead in our trespasses.
But today, we are made sons of God in Christ Jesus:
"5Even when we were dead in sins, hath quickened us together with Christ, (by grace ye are saved;) 6And hath raised us up together, and made us sit together in heavenly places in Christ Jesus:" (Ephesians 2:5-6)
Thank God that He sent His Son to die for us, to live for us. When Jesus was raised from the dead, His resurrection signalled that we were fully justified in Him (Romans 4:20; Acts 13:38-39).