The story
Probably a humorous antonym of bad egg (“someone whose behaviour is reprehensible or irresponsible; a rogue”). The earliest known usage of the phrase was by Rudyard Kipling in his 1904 book "Traffics & Discoveries": "'Good egg!' quoth Moorshed, and brought his hand down on the wide shoulders with the smack of a beaver's tail."
Etymology from Wiktionary, CC BY-SA 4.0.