According To Resent Research Scientist Able to find out that Earth Core Formed 4.5 Billion years ago.
Earth Core is made of Iron ( 85℅), Nickel (10℅) and remaining 5℅ are light elements like hydrogen, Silicon, and Sulpher.
Due to Process called Differentiation liquid metal go inside to Earth. Because of extreme pressure a molten network is formed and molten iron squeezed down through the rocks. It will take Million of years before molten iron reach the core
Temperature of Earth Core is about 6000°c and pressure 3.6 Million times that at the Surface of the Planet.
Because of this huge pressure the molten material does not boil and hold it together.
Cause Of The Earth Magnetic Field:
Due to the motion of the liquid outer core and circling the Earth rapidly, which produced a magnetic field. The outer core contains a large number of charged particles, and when those charged particles move, they make the Earth act like a gigantic magnet.
The core, which is the deepest region of Earth, is composed of a liquid outer core (2900~5100 km in depth) and solid inner core (5100~6400 km in depth).
More Information:
Source:
https://www.scientificamerican.com/article/why-is-the-earths-core-so/
http://study.com/academy/lesson/core-of-the-earth-facts-composition-layers-temperature.html