Eggs are rich in protein, especially the egg whites. It's this protein that causes eggs to become hard when boiled.

Hint
If you don't use a hard-boiled egg (which you must keep in the refrigerator) within seven days, toss it!

Here's how it works:
Protein is a chain of amino acids. These amino-acid strings fold back on themselves (the way the strings fold determines the protein's chemical and biological properties). The proteins are held in place by weak bonds (non-covalent) between different parts of the amino-acid string. When you break those strings, by various methods, you are denaturing the protein.

You can denature a protein in several different ways. Here are two ways to do it with eggs:

Heat - When you heat an egg, the proteins gain energy and literally shake apart the bonds between the parts of the amino-acid strings, causing the proteins to unfold. As the temperature increases, the proteins gain enough energy to form new, stronger bonds (covalent) with other protein molecules. When you boil an egg, the heat first breaks (unfolds) the proteins, and then allows the proteins to link to other proteins. As the proteins form these new, strong bonds, the water that surrounded each protein molecule when the egg was liquid is forced out. That's why the egg turns hard. (Heat affects all of the proteins in an egg, so it's the best way to cook an egg.)


Chemicals - You can also break the weak bonds between protein molecules with chemicals. According to an experiment done by the BBC Science Shack, if you put vodka on an egg white, the alcohol in it breaks weak hydrogen bonds in the protein. If you put vinegar on an egg white, the acid in it breaks ionic bonds. If you mix the two (vodka and vinegar), you break both types of bonds and quite effectively denature the protein. Lots of other chemicals will also break those weak bonds. This won't work as well on the yolk, which, while also protein-rich, has lots of fats and other properties that make it more difficult for it to become hard. You can do something similar when you whisk egg whites: By exerting mechanical energy in the whisking process, you cause the protein bonds to break, and subsequently re-connect. Once these new, strong bonds are formed, the egg stays in that state. The proteins have formed a network of strong, permanent cross-links. A cooked, chemically-altered or well-beaten egg will never go back to its original state.

When cooking eggs, use moderate heat. High heat causes the protein in eggs to become tough and rubbery. When you use high heat to boil an egg, it causes a chemical reaction between the yolk and the white that leaves a green film around the yolk. That film is iron sulfide, caused by iron in the yolk reacting with hydrogen sulfide in the white. It won't hurt you to eat it, and the egg will taste the same, but it sure looks awful!