Went to Gloucester
In a shower of rain.
He stepped in a puddle
Right up to his middle
And never went there again'
The origins of this rhyme are reputedly found in the 13th century although the rhyme was probably made up much later.
King Edward I (1239-1307), whose nickname was 'Longshanks' because he was over 6ft tall, had gone on a visit to Gloucester. Whilst he was there he allegedly fell from his horse and landed in a deep, muddy puddle. He was so embarrassed by what had happened that he vowed he would never visit Gloucester ever again!
Clearly they couldn't make up a rhyme about King Edward I falling from his horse as that could have been construed as mild treason so the name Doctor Foster was made up to rhyme with Gloucester.
The rhyme also acts as a warning. Be careful when stepping into puddles. They may look shallow enough but they could in fact be a lot deeper than you expect!