What brings the speaker out of his mood of dejection and despair is remembering the person to whom this famous sonnet is addressed. Because the speaker knows himself to be loved by this person, it makes him feel metaphorically so rich that he would refuse to change his situation with kings.
Shakespeare sometimes used many metaphors or similes in his sonnets, as in sonnet 73, and sometimes only used a single one. In sonnet 29 he uses one of his most beautiful similes and places it in what seems to be exactly the right place. It takes up two lines, and the image and the meter seem to soar just as the words suggest;
(Like to the lark at break of day arising
From sullen earth) sings hymns at heaven's gate;
Notice how the alliteration of "s" sounds in "sings," "hymns," and "heaven's" suggest the sound of the skylark singing. Any paper on sonnet 29 would do well to focus on this marvelous simile.