In this sonnet, the speaker compares his lover to a "summer's day" via a metaphor, a comparison of two unalike objects where one thing is said to be the other. He asks if he should compare her in this way, and then he goes ahead and does it, noting that she is actually far superior to a summer day.
The speaker explains that his beloved is more "lovely" and more "temperate" than a summer day for many reasons. First, summer is a season that lasts only a short while; next, the sun sometimes shines a little too hot during the summer and can make things too hot and uncomfortable; third, the light of the sun is sometimes not bright enough because it is dimmed by clouds; and, finally, everything in nature grows less and less beautiful as it ages.
However, the poem's volta, or turn, takes place in the ninth line when the speaker declares that his lover's beauty is like an "eternal summer" that will never fade, unlike everything else in nature whose beauty will inevitably die. The speaker says that his lover will never become less beautiful and her beauty will never die because he has written these "eternal lines to time" about her and her beauty. He declares that as long as men live and their eyes can see, his words will live on and continue to keep his lover alive as well.
Thus, the metaphor contributes to the overall meaning of the poem because of the contrast between the shortness of summer versus the speaker's eternal love and the way he immortalizes her beauty.