In this meaningless life of mine I have seen both of these: a righteous man perishing in his righteousness, and a wicked man living long in his wickedness. Do not be overrighteous, neither be overwise - why destroy yourself? Do not be overwicked, and do not be a fool - why die before your time? It is good to grasp the one and not let go of the other. The man who fears God will avoid all extremes.
Here, Solomon plays the part of devil's advocate to show us how he wants us to walk in the middle of the road. He tells of how he has seen those who serve God die young while those who do not live many years on this earth. He basically says that you can live a longer life if you don't offend anyone with your righteousness (walk in the middle of the road). You won't make any enemies to plot against you and everyone will get along. He goes on to say that the devil does not want us to be overly wicked and we might ask ourselves: "Why?" The answer is that, deep down inside all of us, God has placed a conscious and even the most vilest of offenders has a line of morality that they will not cross. The devil does not want us to get to that point because he knows that, if we do, we will see the need for a Savior. Solomon goes on to show us how people will twist the Word of God in an attempt to get us to accept this compromise. Today, there are efforts (even within the body of Christ) to get us to compromise (walk in the middle of the road) and they even go so far as to say that there are many paths to a right relationship with God. Although this sounds good, it is a lie that is being used to set many people up for destruction.