"For at the window of my house I looked out through my lattice"
This simple statement reminds us of so much about sin. Notice that Solomon was looking out of the lattice of his house. His house would have been one of the biggest houses of the city. It would have been on one of the highest points of the city -- God's house being the highest and then the king’s house. He could literally look out over the whole city just as his father David had done when he spied Solomon's mother, Bathsheba, taking a bath on the roof which led to their adultery, Uriah's murder, and David's eventual marriage of Bathsheba, the baby's death, and then Solomon's birth.
Solomon could see the whole city through his lattice, which meant that the young man could not see him. Solomon probably knew who the man was and that he did not belong in that part of the city and that the woman who came to see him was not his wife. There is always someone watching. Sin seems private and hidden, but there are people who are watching. God is watching and someone else is aware.
What you are doing will come out. We have blinders on when we are in the pursuit of sin, which makes it seem as though our sin is more private than it is. I know a man who was having an affair that he thought no one could know about. He was proud of how he had deceived everyone, and yet it became known and his denials and deception just broke trust to a deeper level. Realize that your sin will find you out.
Solomon is introducing a real life story to describe the deceptiveness of sin and the naiveté of the sinner. He goes on in this section to describe the actions, words, and even thoughts of adulterers and adulteresses. He also does something that few do in these kinds of detailed descriptions of the course of sin. He gives the consequences of following this course of action in verses 23, 26, and 27.