While interpreting and exegeting Ecclesiastes we need to keep in mind a couple of things. First, the preacher's observations and comments, for the most part, concern things "under the sun." True believers know, however, there is a meaning to life which transcends just the things under the sun, as good as those things might be. (One such good thing, as the preacher observes, is the enjoyment of one's work under the sun.)
Second, statements such as "be not over-righteous or over-wise" have a primary application to living life among the "heathen," shall we say. In modern parlance, we might say,
No one likes a goody-two-shoes.
No one likes a wisenheimer/smart_ _ s/wiseguy.
Who do you thing you are, acting all high and mighty?
So, why the "holier than thou" attitude?
To get along with people in the world (since we ourselves are IN the world but not OF the world, and the world's system/kingdom), we need to be wise as serpents but harmless as doves, as Jesus said.
In our praying, giving, and fasting, we need to be invisible--except to our heavenly Father!
To be overly righteous or wise is to risk destroying one's life unnecessarily. According to the Bible, Christians need to "fit in" as any good ambassador does, but not to go completely "native." Again, they are in the world but not of the world.
There's a fine balance there. Daniel, of the book bearing his name, achieved that balance. He was educated by heathens, but he took his faith in God more seriously. When the time came for him to choose either to bow down before the king's likeness or to maintain his integrity before God, he chose the latter.
In conclusion, Christians need God's righteousness and wisdom, but they needn't wear it on their sleeves. To do so is to risk destroying their testimony before a watching world.