In Shakespeare's Sonnet 18 ("Shall I compare thee to a summer's day"), the poet is comparing the subject of the poem with nature.
Though the summer is a beautiful time, the object of the poet's praise is even more "lovely and more temperate." Unfortunately, the winds wreak havoc with the gentle blossoms that bloomed in the spring ("May"). And in the summer, the sun can sometimes be terrible fierce ("too hot the eye of heaven shines"). He goes on to write that there is always an eventual decline in nature, with the passing of summer. So there is the question, "Shall I compare thee...?"
The pivotal point of the poem rests on the first word of the ninth line: "But..." Shakespeare summarizes an idea in the first two quatrains (four-line stanzas), but then shifts his focus in the first line of the third quatrain. In this case, he is saying that for all that happens in terms of nature and the summer, the object of his praise will NOT follow the same path: "...thy eternal summer shall not fade," even as time passes, even when death comes.
The couplet is used to draw the sonnet to its conclusion, but to present a summary of Shakespeare's thought: as long as there are people left to read this sonnet, the beauty and life of this person will be immortalized.
Whereas the beginning eight lines speak literally of a day in summer, the third quatrain becomes more figurative, metaphorical. The beauty of the poet's subject will not fade (literally, it will) or be less "fair;" death will not be a threat (though literally, it will), when this person looks towards dying and eternity. In a literal sense, the ravages of time will leave their mark, and death will come.
However the rhyming couplet works because Shakespeare (or the speaker) is saying that in the sonnet, time will not pass, and the object of the poem will be immortal, as if he or she were frozen in time at that very moment.
I am not sure to what extent we can apply the world of logic and reason to the world of literature, emotion and love. Certainly the last couplet of this famous sonnet of Shakespeare probably don't make much logical sense, but I guess to understand and fully appreciate poetry you have to suspend your logical faculties and try and embrace the imagination. Let us just remind ourselves what the last couplet says:
So long as men can breathe, or eyes can see,
So long lives this, and this gives life to thee.
These last two lines are actually an example of a convention that is known as an eternalising conceit, which suggests that the sonnet itself immortalises or gives eternity to the human love explored in this poem. The whole sonnet is a celebration of how the "eternal summer" of the youth addressed in the sonnet will not fade like everything else. This is because, as the last couplet states, so long as there are humans around, this sonnet will remain. And as long as that happens, the beauty of the youth will be "given life" and resurrected in Shakespeare's poetry. So, perhaps not much logical sense, but a beautiful ending to a beautiful sonnet.