The main way that scientists have been able to determine the makeup of the interior of the Earth is by studying how seismic waves pass through its various layers. In addition, they have also made theories about the composition of the core of the Earth by studying its magnetic fields.
Scientists know that shear seismic waves, such as those produced by earthquakes, cannot properly travel through liquid. When an earthquake occurs on earth, scientists are able to measure these waves for some time, until they reach the earth's inner core. As the waves disappear when they reach the inner core, scientists have been able to determine that it is composed of liquid. However, the waves then reappear after some time, leading scientists to theorize that the outer core must be made of liquid, while the inner core is a solid.
Still, these seismic waves only provide information about the state of the various layers and not of what they are composed. However, by studying the magnetic fields of the Earth, scientists have also been able to determine that both the inner and outer cores are composed primarily of iron, as the planet would not be able to have a magnetic field if this were not the case.