There are lots of different ways to write a sonnet, which is basically just a particular kind of short poem. Shakespeare's sonnets have a very specific form, though, and scholars have named that form after him. Shakespearean sonnets have several things in common:
They are 14 lines long.
They are written in iambic pentameter. For example, you could scan line 11 as follows: "Shall sum my count and make my old ex-cuse."
Usually, they include a feature called a "turn." This is a moment in the poem where the theme or the tone changes in a surprising way. In Sonnet 2, the turn comes at line 9, where it switches from scary thoughts about old age to the possible solution of having kids. Line 9 marks the point where the poem moves from the setup to the payoff.
The first twelve lines rhyme in alternating pairs. To show how this works, we can assign a letter to each rhyme: We'll show you how it works for the first eight lines:
When forty winters shall besiege thy brow, A And dig deep trenches in thy beauty's field, B Thy youth's proud livery, so gazed on now, A Will be a tatter'd weed, of small worth held: B Then being ask'd where all thy beauty lies, C Where all the treasure of thy lusty days, D To say, within thine own deep-sunken eyes, C Were an all-eating shame and thriftless praise. D
For the whole poem the rhyme scheme would be: ABABCDCDEFEFGG.
See those last two letters at the end (the GG)? That's the last important thing to know about the form of a Shakespearean sonnet. They always end with two rhyming lines, one right after the other. We call this a rhyming couplet. Here's the couplet from the end of Sonnet 2:
This were to be new made when thou art old, And see thy blood warm when thou feel'st it cold.