This a derogatory phrase used to describe a person who is unpopular or completely out of favour due to some act. The obvious allusion might seem to be one of someone so low in society’s opinion that they are no better than mud, but this is not the origin of the phrase.
On 14 April 1865 John Wilkes Booth assassinated President Abraham Lincoln in the Ford Theater, Washington DC. As he made his escape Booth broke his leg, but still managed to reach his horse and ride away. When he reached the countryside he looked for the house of Dr Samuel Mudd who treated his injury. Mudd had no idea of the events of the evening but, when he heard of the assassination the following day, he immediately informed the authorities he had seen Booth. Despite his innocence, the doctor was arrested and later convicted of conspiracy and sentenced to life imprisonment. In 1869 Mudd was pardoned and released from jail, but the American public never forgave him for his implied involvement in the assassination plot. It would be another hundred years before poor old Mudd was finally declared innocent and his name cleared.