Why is Earth's density gradient a step-function, rather than smooth?
Roughly put, it's the same thing that makes a density step function when you try to combine oil and water:
Source
The components do not mix with or dissolve into each other, so gravity makes the denser material -- water -- settle to the bottom.  The density as a function of height jumps up from the oil density to the water density when you go below the interface.
In the case of Earth, there are several progressively denser phases that do not mix.  The biggest step in the density gradient is when the rock phases (olivine, spinel, perovskites, and ferropericlase which is not shown in the illustration below) give way to the much denser core.  In the illustration below, this boundary is where the bottom part of the rocky mantle, the D&quot; layer, meets the predominantly iron core.
Source
One major difference between the interior of Earth and the oil-water combination in the first picture is that much of Earth's interior is solid, so it takes a lot of heat and pressure -- both generated by gravity -- to make the materials yield and flow to their equilibrium positions.  The same is true of other predominantly solid celestial bodies, so only relatively large and massive ones have enough gravitational power to enable separation of different density phases.  Planetary scientists call this process differentiation.