Rabbi Moshe Ben-Chaim
“Wisdom is more valuable than weapons of war, but a single error destroys much goodness” (Koheles 9:18)
Both statements compare a value to something lesser. The effects of wisdom outshine the power of the sword, which by comparison is lacking, because brute force doesn't yield the success of wisdom and strategy. This is in the area of the practical. But in the area of character perfection, “but a single error destroys much goodness.” So in both areas—external practicality and internal perfection—King Solomon is telling us to gauge what is truly of greater value. He enlightens us to a misconception where we place greater value on A than on B. But King Solomon teaches us that we sometimes are incorrect about what is of greater value. This is what the 2 halves of the verse have in common. We typically look at might as more formidable than intelligence, but this is wrong: as they say, “The pen is mightier than the sword.” And equally, we look at much good as more formidable than a single error or sin. Again, we are wrong because when our error or sin is severe, it can obliterate tremendous amounts of our previous good deeds. The lessons are not to value might as an absolute practical solution, and neither to value vast quantities of good actions as an absolute security in our lot with God. Sin places our mitzvahs and goodness at risk.
Just before this King Solomon elaborates on the greatness of wisdom:
This thing too I observed under the sun about wisdom, and it affected me profoundly. There was a little city, with few men in it; and to it came a great king, who invested it and built mighty siege works against it. Present in the city was a poor wise man who might have saved it with his wisdom, but nobody thought of that poor man [to ask his wise help]. So I observed: wisdom is better than valor; but a poor man’s wisdom is scorned, and his words are not heeded. (Ibid. 9:13-16)
The same applies to Joseph's salvation of Egypt and the surrounding countries. Wisdom saved everyone from the famine.