Like many ancient verses, this nursery rhyme/song is grounded firmly in fact. The original capital of England was not London but Colchester—or Camulodunum as it was known in Roman times—but in AD 43, the Romans established Londinium, known later as London. The Romans built a number of bridges across the River Thames that didn't survive.
The London Bridge referred to in the song was commissioned by Henry II at considerable cost. In 1176, work was started on the stone structure, supervised by Peter of Colechurch. Henry died in 1189, but the bridge was not finished until 1209 under King John, of Magna Carta fame.
When London Bridge was completed it had shops and houses on it, and for five hundred years it was the only bridge across the Thames in London.
"London Bridge Is Falling Down" is included in the Roud Folk Song Index at 502. It is also known simply as "London Bridge" or "My Fair Lady".
According to the art historian and TV presenter Dan Cruikshank, who researched the original charter at the Corporation of London Archive, the authorities began planning London Bridge in 1173.
Once the bridge was built, it had to be maintained, and this, said Cruikshank, is the key to the nursery rhyme. The cost of maintenance was paid for out of tolls, on both people and ships, but sometimes the money went astray. In 1282, during the reign of Henry III, five of the bridge's 19 arches collapsed. About 5 years earlier, Henry had given the revenues from the bridge to his wife, Queen Eleanor, and she had spent it on herself!
Queen Eleanor is said to be the My Fair Lady alluded to in the rhyme (there are other candidates and explanations, but she seems the most likely one). This led to the City of London taking back the revenues from the bridge from the Crown and giving it to the people, the Bridge House Estates, which still exists today.
There are various melodies associated with the rhyme, but the one most commonly used was first recorded in 1879, in the USA. (thanks, Alexander Baron - London, England, for all above)
Folklorists Iona and Peter Opie reference a haunting theory behind the rhyme in the Oxford English Dictionary of Nursery Rhymes. The watchman appointed to protect the bridge is no ordinary man, but a supernatural guardian. They link the lyrics to primitive "foundation sacrifices," whereby a captive is buried alive to forever watch over the structure. They explain: "Bridge building is a hazardous undertaking, and it has long been thought sensible to propitiate the river with a sacrifice, a human life if possible."
The rhyme may or may not be connected to these types of legends, but the actual London Bridge thankfully shows no evidence of such sacrifices.