Final answer:
The Earth's magnetic field is produced by the flow of a liquid iron alloy in the Earth's outer core, which is 2,255 km thick and surrounds a solid inner core.
Step-by-step explanation:
The Earth's magnetic field is generated by the movement of liquid iron alloy in the outer core. The liquid iron alloy is 2,255 km thick and its flow creates electric currents which, in turn, produce the magnetic field. This liquid outer core is surrounded by the mantle, which is made up of solid rock that can slowly deform and flow.
The mantle has variable densities that increase with depth due to compression from overlying material. The core's composition is not limited to iron; it also includes elements like nickel and sulfur, all compressed to achieve very high densities.
The solid inner core is surrounded by this flowing liquid, which contributes to the generation of Earth's magnetic field, mirroring the effect seen when a large current produces a significant magnetic field around a long straight wire.