Here's why:
* The outer core is liquid: Composed primarily of iron and nickel, the outer core is in a liquid state due to the immense heat and pressure. This fluidity is essential for the generation of the magnetic field.
* Convection currents: The heat from the Earth's inner core creates convection currents within the liquid outer core. This movement of molten metal generates electrical currents.
* Dynamo effect: The electrical currents, combined with the Earth's rotation, create a magnetic field through a process called the dynamo effect.
Therefore, the magnetic field of Earth is not generated in a specific "layer," but rather within the liquid outer core due to the interplay of heat, convection, and rotation.