The origin of this phrase does not
come from getting a rotten egg within a dozen once in awhile. According to Common Phrases (Mordock and Korach), it comes from a notorious American criminal named Egg. He paid for his crimes under the law and at society's hands, as well. His name became used to describe a thoroughly nasty person, a bad egg
Kind of like his name is Mudd
. One story says that this phrase came out of Dr. Samuel Mudd helping fix the leg of John Wilkes Booth after Booth assassinated Abraham Lincoln. Dr. Mudd said he had no idea of what Booth had done and informed authorities the following day of his encounter with Booth. Dr. Mudd was convicted of conspiracy by a military court, though he wasn't a soldier, and sentenced to life in prison. He was pardoned 4 years later in 1869 after he stopped a yellow fever epidemic at the prison; but his name remained synonymous with doing something bad. Since the 1930s, the Mudd family has been trying to clear his name and have the conviction overturned. It seems that it is still up in the air. Apparently, no one seems to have authority to overturn the verdict since it was a military tribunal and Dr. Mudd accepted the presidential pardon, making the conviction moot. Others question his pleas of innocence because he was allegedly a confederate sympathizer and was acquainted with Booth despite protests to the contrary.
Another story says that his name is mud
was in use for at least 45 years prior to this incident. Mud
was a slang term for a stupid person, a dolt or fool.