Shakespeare's sonnet rhyme scheme is taken from experiments made by Wyatt and Howard, the Earl of Surrey, on Petrarch's Italian sonnet rhyme scheme. They independently adapted Petrarch's form to suit English words and idea constructs. Shakespeare used one of the experimental forms and honed it to perfection.
Let's compare Shakespeare's sonnet rhyme scheme, also called English sonnet rhyme scheme, to Petrarch's for a full picture of Shakespeare's scheme. Petrarch's sonnets developed one topical thought that turned in emphasis at what is called the Petrarchan volta at line 9. Then the problem in the topic is presented. It is resolved the final paradoxical lines of the sestet. He used eight lines in an octave to present the topic. He used six lines in a sestet to present the turn (volta) in topic and the paradox of the ending resolution. Thus Petrarchan structure is an octave joined to a sestet with no ending couplet. The octave always followed the abba abba rhyme scheme, with aa linking (concatenation) at lines 4 and 5. The sestet had various alternate rhyme schemes like cddcdc or cdeced.
Soleasi Nel Mio Cor by Petrarch (translation Thomas Wentworth Higginson)
She ruled in beauty o'er this heart of mine, a
A noble lady in a humble home, b
And now her time for heavenly bliss has come, b
'Tis I am mortal proved, and she divine. a
The soul that all its blessings must resign, a
And love whose light no more on earth finds room, b
Might rend the rocks with pity for their doom, b
Yet none their sorrows can in words enshrine; a
They weep within my heart; and ears are deaf c
Save mine alone, and I am crushed with care, d
And naught remains to me save mournful breath. c
Assuredly but dust and shade we are, b
Assuredly desire is blind and brief, e
Assuredly its hope but ends in death. c
Shakespeare made modifications to this rhyme scheme. He introduced two voltas, lines 5 and 9, so he might have two subjects of discussion under one topic; one in the first four line quatrain and one in the second quatrain. The third quatrain provides the problem that is resolved in the paradox of the ending rhyming couplet. Shakespeare's structure is three quatrains and an ending couplet; this structure sets the stage for his rhyme scheme of abab cdcd efef gg.
Sonnet XXIX by Shakespeare
When in disgrace with Fortune and men's eyes, a
I all alone beweep my outcast state, b
And trouble deaf heaven with my bootless cries, a
And look upon myself and curse my fate, b
Wishing me like to one more rich in hope, c
Featured like him, like him with friends possessed, d
Desiring this man's art and that man's scope, c
With what I most enjoy contented least, d
Yet in these thoughts my self almost despising, e
Haply I think on thee, and then my state, f
(Like to the lark at break of day arising e
From sullen earth) sings hymns at heaven's gate, f
For thy sweet love remembered such wealth brings, g
That then I scorn to change my state with kings. g
You can see how each quatrain, with its own rhyme set, can easily be dedicated to a separate subject under one topic; that lines 5 and 9 might elegantly turn, or produce the two voltas; how the triple quatrain structure with independent rhyme sets also accommodates a sonnet that carries one subject for two quatrains without a volta at line 5, creating a vivid image of one idea. The resolution to the problem or continued idea of the third quatrain is dramatically set off by the paradox of the gg couplet.
Normally the typical Shakesperean sonnet is rhymed as abab cdcd efef gg. This means that lines 1 and 3 rhyme and 2 and 4 rhyme, then continuing to alternate until the last two rhyme.