In Shakespeare's Sonnet 29, "When in disgrace with Fortune and men's eyes," the author (who could be any man, not necessarily Shakespeare) starts the sonnet by speaking of his life.
In William Shakespeare's sonnets, he uses the structure of the sonnet to organize his ideas. Every stanza of four lines is called a "quatrain." There are three of these that account for twelve lines; the last two lines are a rhyming couplet: they rhyme with each other.
The organization Shakespeare used was: the first two quatrains (eight lines) presented an idea. In line nine, the focus of the sonnet shifts. The third quatrain presents a different approach to what was introduced in the first eight lines. The rhyming couplet at the end is used as a conclusion, summarizing or driving home the most important point of the poem.
In the first two quatrains, the speaker talks of how terrible his life is: his has bad luck and gets no respect ("When in disgrace with Fortune and men's eyes"); he is lonely and depressed ("I all alone I beweep my outcast state"); heaven won't listen to him ("and trouble deaf heaven..."); and, he looks at his life and hates it ("And look upon myself, and curse my fate...).
The same tone continues in the second quatrain: he wishes he had more to look forward to, looked handsome like another man or had his friends ("Wishing me like to one more rich in hope, / Featured like him, like him with friends possessed..); he wishes he had another man's talents or intelligence ("Desiring this man's art and that man's scope:); and, he finds himself unhappy with that which brings him the most happiness ("With what I most enjoy contented least").
Now, on line nine, the word that identifies the shift of the author's ideas and tone is "yet." It is almost as if he has said, "But wait a second." And here, he changes the direction of his ideas: it is a sudden and enlightening shift. The sonnet becomes a love poem:
Yet even when I almost hate myself ("Yet in these thoughts myself almost despising"); when I think about you, my attitude changes completely and I feel the same joy a bird taking flight to sing at the gates of heaven feels ("Haply I think on thee: and then my state, / Like to the Lark at break of day arising / From sullen earth, sings hymns at Heaven's gate").
The rhyming couplet summarizes all of this, and it is powerful:
When I remember that you love me, it brings such elation to my heart and soul, that I wouldn't exchange places with kings ("For thy sweet love rememb'red such wealth brings / That then I scorn to change my state with Kings.")
Watching the sonnet's organization, one can understand that at first the speaker hates his life; then he thinks about the woman who loves him and his problems disappear: because when he thinks of her, he would not change places with the richest, most important man on the planet.