Here's why:
* Iron and Nickel: The Earth's core is primarily made of iron and nickel. These metals are excellent conductors of electricity.
* Sulfur: Sulfur is present in the core, and it's believed to play a role in the core's properties, but it's not the primary component.
* Oxygen: While oxygen is abundant in the Earth's crust and mantle, it's not a major component of the core.
* Magnetic Field: The Earth's magnetic field is generated by the movement of molten iron in the outer core. This movement is driven by heat from the Earth's interior and the rotation of the Earth.
In summary: The Earth's core, specifically the molten outer core, is responsible for generating the magnetic field due to the presence of iron, nickel, and the movement of these materials.