Various theories suggest that Earth's iron may have originated from (1) extraterrestrial sources and (2) processes occurring during the planet's formation.
As per one of the most popular theories, "the relatively large size of the planet created high pressure and high temperature conditions during core formation that made different proportions of heavy and light iron isotopes accumulate in the core and mantle."
Second, Why inner core of the earth is rich of iron?
During the planetary differentiation processes, droplets of iron, nickel, and other heavy metals gravitated to the center of Earth, becoming the early core.