In Eccl 7:15-18, Qoheleth discusses the problem of the value and balance of righteousness and wisdom. He has concluded that human wisdom cannot really explain all of life nor the future (6:10-7:14), and that even the principle that righteousness brings prosperity has many exceptions (7:14-15). He offers helpful counsel: Do not strive for exaggerated righteousness or try to make yourself the wisest person on earth, for these are not really worthwhile goals; and in the end, such striving will ruin your life. Likewise, do not turn to immorality or act like a fool, since God's principles do still operate and you will put yourself in danger of premature death. What then of righteousness and wisdom? what good are they? Qoheleth answers that they are both of great benefit.
Brindle, Wayne, "Righteousness and Wickedness in Ecclesiastes 7:15-18" (1985). SOR Faculty Publications and Presentations. 105.