A Shakespearean sonnet usually ends with a "turn" in the final couplet. This means that the subject of the first twelve lines is considered from a different perspective, or that the poet adds a new idea to the argument he has been making. In Sonnet 18, the poet has been comparing his beloved with a summer's day, to the advantage of the beloved. None of the factors which might spoil the summer's day are present in the addressee, who outshines it in every way.
The final point Shakespeare makes is that unlike the summer's day, the subject of his sonnet is immortal. This is a larger claim than the reader expects. It is true that young lovers last longer than summer's days, but they do not last forever. The poet, therefore, explains in the last two lines,
So long as men can breathe or eyes can see,
So long lives this, and this gives life to thee.
This is an unusually decisive turn. The subject changes from the beloved to the poem itself. As long as there are seeing, breathing men in the world, they will read this poem, and this poem gives life to the addressee.
This change of focus is given an added point by the fact that the reader has just proved the first assertion correct (or at least reasonable) by reading the poem. It is, however, highly debatable whether the poem has given life to the beloved, since the reader learns nothing about them. Even the idea that the addressee is a young man rather than a woman is supplied by context from the other sonnets and is not discernible from this poem alone. The final couplet, therefore, not only changes the perspective of the reader to focus on the poem itself, but reveals how the poem and the poet's art have been the central themes throughout.