The iron in the earth's core is solid due to high pressure.
At the center of the earth is solid inner core, whose size is two-thirds of moon's size mad made up primarily of iron. The temperature in this core is equal to that of the sun's surface at 5,700 degrees Celsius. But the tremendous pressure caused by gravity prevents the iron from becoming liquid.
Surrounding this is the outer core made of nickel and small quantities of other metals and these remain liquid because the pressure here is a bit lower.