According to Wiki:
The term “Tom O’Bedlam” was used in Early Modern Britain and later to describe beggars and vagrants who had or feigned mental illness (see also Abraham-men). They claimed, or were assumed, to have been former inmates at the Bethlem Royal Hospital (Bedlam). It was commonly thought that inmates were released with authority to make their way by begging, though this is probably untrue. If it happened at all the numbers were certainly small, though there were probably large numbers of mentally ill travellers who turned to begging, but had never been near Bedlam. It was adopted as a technique of begging, or a character. For example, Edgar in King Lear disguises himself as mad “Tom O’Bedlam”.