Eggs can turn green when microwaved due to a chemical reaction that occurs between the iron in the yolk and the sulfur in the egg white. This phenomenon typically happens when the egg is overcooked or microwaved for too long at too high of a power setting.
Egg yolks contain iron, and egg whites contain sulfur. When heated rapidly in the microwave, the high heat can cause some of the iron to migrate from the yolk to the egg white. The iron then reacts with the sulfur in the egg white to form ferrous sulfide. Ferrous sulfide is a greenish compound, which is responsible for the greenish color seen in overcooked or microwaved eggs.
The green coloration doesn't necessarily mean the egg is unsafe to eat, but it does indicate that the egg has been overcooked and may not taste as good as properly cooked eggs. To avoid this, it's essential to cook eggs in the microwave with caution and follow appropriate cooking times and power settings. If you prefer to microwave eggs, it's best to use low to medium power and check them frequently to prevent overcooking. Alternatively, other cooking methods such as stovetop boiling or poaching can yield better results with eggs.