Shakespeare drew from multiple sources including Raphael Holinshed's Chronicles of England, Scotland, and Ireland and Geoffrey of Monmouth's History of the British Kingdom
The character of Poor Tom or the Bedlam Beggar, as which Edgar disguises himself, is based on vagabonds or madmen considered dangerous in England at the time. "Bedlam" was a slang word for "Bethlehem," which was the name of a mental institution in London.
There are actually two different versions of King Lear — The History of King Lear published in quarto form in 1608 and The Tragedy of King Lear, which was published in the First Folio (1623) and is very substantially revised from the play published in 1608. Before the 1990s, editors usually "blended" the two texts, taking what they believed were the best versions of each scene. In recent times, some editors have started focusing on the "original" 1608 edition.
In Shakespeare's day, the roles of Cordelia and the Fool were often "doubled"—played by the same actor—since the two characters are never on stage at the same time. Shakespeare alludes to this fact at several points in the play. The first time that Lear summons the Fool, in 1.4, both he and his Knight observe that the Fool has been melancholy ever since Cordelia was sent to France. More famously, in 5.3, upon learning of Cordelia's death, Lear remarks "And my poor fool is hanged" (5.3.369). Sometimes directors staging the play invent a scene in which the Fool himself is hanged, to explain this line, but the tradition of doubling the characters is the better explanation.