This verse is the beginning of a long poetic proverb (:6-27) which Solomon tells his son. Most likely it was not a literal observation Solomon was sharing, but a wise saying to impart insight.
Maybe it was even a well-known proverb of the day that Solomon just passed along to his boy. Either way, it’s about bad choices, deception and the price we pay for both.
We can all relate to the story on some level because we have all done some pretty embarrassing stuff over the years. Here we are reminded that what we do is seen by someone.
It’s amazing how things we do seemingly in secret somehow gets known. Of course, God always sees what we do.
By the way, this verse interests me as an archaeologist. The “window” of Solomon’s palace did not have glass, but a “lattice” work.
Poor people would have hung a mat in their windows, not so much for privacy but to keep the elements out. Rich people would used lattice-work of stone of some other material to go along with the mat. I have seen such in Egypt.
Go ahead and read this long proverb for yourself. There are plenty of other notes of interest to archaeologists, but the real message is to remember that Somebody is watching!