The basic scheme is to first localize and characterize a set of significant earthquakes. These earthquakes are them considered to "illuminate" the interior of the earth with seismic waves.
The time that the waves arrive at seismic stations can then be used to calculate the waves' speed through the Earth. By combining analyses from many earthquakes, in different places around the Earth, a three dimensional map of wave speed through the Earth can be constructed.
Scientists using this map, then assume that the material is a similar chemical composition to deep borehole rocks and magma. These assumptions permit then to construct an internal map of the density and rock types of the Earth's core.
See also seismology, seismic wave, seismograph