In Solomon's day the king had far-reaching power over his subjects. Therefore it became imperative to avoid his wrath. We must keep this background in view because it lies behind what Solomon said in chapter 8.
8:1 A wise man understands things that a fool does not. Moreover he is able to behave appropriately. One's facial and general appearances reflect wise behavior (cf. Num. 6:25; Prov. 7:13).
8:2-4 The wise man behaves appropriately in the presence of his king. He keeps his oath of allegiance that he has made before God (v. 2). He does not resign from his service (v. 3a) or join in a revolt against the king (v. 3b). Furthermore he does not dispute the king's authority and sovereignty (v. 4).
8:5-7 The wise person also knows when and how to speak and act (v. 5). Often people suffer harm as a result of not knowing what will happen and when (vv. 6-7). Consequently they misdirect their words and deeds.
8:8-9 Verse 8 means that no one can escape the consequences of his or her own wickedness. The idea is that the king will punish him or her (v. 9). Thus it is important to have wisdom.