AstroChuck is half right…
According to The American Heritage Dictionary, the phrase “a good egg” is an agricultural term dating back to civil war times and was the converse of “a bad egg”, which wasn’t in a saleable condition. These terms were not just used to refer solely to eggs, and were in-fact employed widely when discussing a number of agricultural products. For this phrase to then be used to relate to people is only a natural transition.
Interestingly, there is actually some controversy regarding the phrase “a good egg” in England. Around 1915, there are somewhat mixed reports that police were instructed “not to use the phrase ‘good egg’, because it was too closely linked with egg and spoon, rhyming slang for coon, an offensive racial slur.” (See: http://www.worldwidewords.org/topicalwords/tw-goo1.htm)
a bad egg (mainly American, informal)
someone who behaves in a bad or dishonest way. He’s a bad egg – don’t believe anything he says.
Hope this helps!