Remember that ad campaign a while back, that was meant to show you that eggs weren't bad for you? Turns out, they understated the case. Eggs are desperately trying to save your life. The "green" on boiled eggs shows where they saved you from your own attempts at chemical warfare.
Hydrogen sulfide is a toxic gas, flammable and much-feared by miners. It lurks in low wells and caves, and can suffocate, poison, or explode people. It's also what you make on the stove when you're boiling eggs – especially when you overboil them. Despite the fact that you are attempting to eat them, the eggs are trying desperately to save you from your folly. For evidence of this, just crack open a hard boiled egg that's been overcooked, and see the gray-green yolk.
The hydrogen sulfide originates in the whites of the egg. Proteins there contain sulfur that combines with hydrogen to form the deadly gas. The hydrogen sulfide heads toward the inside of the egg because of the solubility gradient. Solubility – the amount of stuff that can be dissolved in liquids – decreases with heat. As the outside of the egg gets hotter, the gas is forced toward the yolk.
The yolk of an egg contains iron. When the iron meets the hydrogen sulfide gas it combines to form iron sulfide – which has a greenish cast to it. The more you overboil an egg, the more iron sulfide is made, and the more green you'll see on the yolks. Most recipes for boiled eggs recommend putting the eggs under cold water as soon as they're cooked to cool them off quickly, and keep the residual heat from over-cooking them. Then again, maybe you take comfort from knowing how to make a deadly gas, if you ever need it.
Image: Andrés Nieto Porras