If the gravity at the center of the Earth is zero, why are heavy elements like iron there?
Forget about force. Force is a bit much irrelevant here. The answer to this question lies in energy, thermodynamics, pressure, temperature, chemistry, and stellar physics.
Potential energy and force go hand in hand. The gravitational force at some point inside the Earth is the rate at which gravitational potential energy changes with respect to distance. Force is the gradient of energy. Gravitational potential energy is at it's lowest at the center of the Earth.
This is where thermodynamics comes into play. The principle of minimum total potential energy is a consequence of the second law of thermodynamics. If a system is not in its minimum potential energy state and there's a pathway to that state, the system will try to follow that pathway. A planet with iron and nickel (and other dense elements) equally mixed with lighter elements is not the minimum potential energy condition. To minimize total potential energy, the iron, nickel, and other dense elements should be at the center of a planet, with lighter elements outside the core.
A pathway has to exist to that minimum potential energy state, and this is where pressure, temperature, and chemistry come into play. These are what create the conditions that allow the second law of thermodynamics to differentiate a planet. As a counterexample, uranium is rather dense, but yet uranium is depleted in the Earth's core, slightly depleted in the Earth's mantle, and strongly enhanced in the Earth's crust. Chemistry is important!
Uranium is fairly reactive chemically. It has a strong affinity to combine with other elements. Uranium is a lithophile ("rock-loving") element per the Goldschmidt classification of elements. In fact, uranium is an "incompatible element", which explains the relative abundance of uranium in the Earth's crust.
Nickel, cobalt, manganese, and molybdenum, along with the most extremely rare and precious metals such as gold, iridium, osmium, palladium, platinum, rhenium, rhodium and ruthenium, are rather inert chemically, but they do dissolve readily in molten iron. These (along with iron itself) are the siderophile (iron-loving) elements. In fact, iron is not near as siderophilic as the precious metals. It rusts (making iron is a bit lithophilic) and it readily combines with sulfur (making iron a bit chalcophilic).
This is where pressure and temperature come into play. Pressure and temperature are extremely high inside the Earth. High pressure and high temperature force iron to relinquish its bonds with other compounds. So now we have pure iron and nickel, plus trace amounts of precious metals, and thermodynamics wants very much to have those dense elements settle towards the center. The conditions are now right for that to happen, and that's exactly what happened shortly after the Earth formed.
Finally, there's stellar physics. The Earth would have a tiny little core of rare but dense elements if iron and nickel were as rare as gold and platinum. That's not the case. Iron and nickel are surprisingly abundant elements in the universe. There's a general tendency for heavier elements to be less abundant. Iron (and to a lesser extent, nickel) are two exceptions to this rule; see the graph below. Iron and nickel are where the alpha process in stellar physics stops. Everything heavier than iron requires exotic processes such as the s-process or those that occur in a supernova to create them. Moreover, supernova, particularly type Ia supernovae, are prolific producers of iron. Despite their relatively heavy masses, iron and nickel are quite abundant elements in our aging universe.
(source: virginia.edu)
There are two different quantities here to distinguish: the gravitational force and the gravitational well. At the center of the Earth, the gravitational force is zero, but the gravitational well is at its deepest. The heavy elements tend to migrate to the lowest point in the gravitational well, so they are at the center, even though the force is zero there.
If I drop a ball here on the surface of Earth, it will accelerate downwards at about $10\, \mathrm{m/ s^2}$ This is because the gravitational force pulls it down. Gravitational force pulls things toward the center of the Earth. As you go higher and higher up, the gravitational force gets weaker. If you go up a tall building, the gravitational force goes down by a few thousandths of a percent, but if you go way out into space, say as far as the moon, it gets much weaker, eventually getting so weak you can barely notice it any more.
As you go down into the Earth, the gravitational force gets stronger because you are getting closer to the heavy stuff at the Earth's center. However, if you go down thousands of miles (much further than we have the technology to go today), the gravitational force will start getting weaker because most of the Earth's mass is above you now and is no longer pulling you down towards the center. So gravitational force maxes out part way down towards the center, then starts fading away. At the very center, the gravitational force is zero because there's equal mass pulling on you from all sides, and it all cancels. If you built a room there, you could float around freely. That's what it means to say that gravity is zero at the center of Earth.
However, the gravitational well is a different story. This is about how much energy it would take to escape Earth. If you're on the surface of Earth, this is about 60 million Joules per kilogram. As you go up, it gets smaller and smaller, and if you go out very far, it effectively falls to zero once you're far enough away that Earth's gravitational pull is negligible.
As you go down deeper into the Earth, you get deeper and deeper into the gravitational well. Even when you're deep in the Earth and the gravitational pull is not very strong, going further down still moves you deeper into the Earth's gravitational well.
The gravitational force and the gravitational well are related to each other. The force is how fast the well gets deeper. When you get deep in the Earth, but not quite at the center, the gravitational force is small. That means that moving further down puts you deeper into the gravitational well, but only gradually. The slope of the well is shallow there, but still getting deeper.
Roughly speaking, the elements in a planet like Earth will try to minimize their energy. They do this by getting as deep into the gravitational well as they can because the deeper they go into the well, the lower their energy. The deep parts of the well do fill up, though, because not everything can fit down at the very center. The energy is minimized by putting the heavy stuff, like iron, down at the center, and the lighter stuff higher up.
This is far from a perfect description of Earth because it's what happens at equilibrium and at zero temperature, and that's not Earth, but it's a decent rough approximation of what happens in Earth.
So your answer is that gravitational force is zero at the center, but gravitational energy is lowest there, and heavy things go to where gravitational energy is lowest, so that's why the center of Earth is mostly the heavy stuff.
Here's an interesting thought experiment.
Imagine you have an elevator shaft to the centre of the Earth which, for some strange reason, doesn't affect the gravitational field of the Earth and doesn't flood with magma.
OK, now at the Earth's surface get a bottle, half full with oil and half full with water. The water is denser than the oil, so the force of gravity on the water is greater than the force of gravity on the oil... so the water sinks to the bottom and the oil floats on the top.
Now, head down your elevator shaft. Is the gravity weaker or stronger here? Well, for our bottle of oil it doesn't really matter. Whatever the gravity is, it still produces a greater force on the water than it does the oil, so the water will always sink.
In terms of materials floating or sinking relative to other materials, it doesn't matter where the gravity is strong of weak, what matters is only the direction of the gravity.
So why isn't the Earth a big sphere of materials layered by density? Well... largely it is. Iron (7,870 kg/m^3) is denser than magma (~2,500 kg/m^3) is denser than water (1000 kg/m^3) is denser than nitrogen (~1 kg/m^3)... and that's the order you generally find them in.
What about the exceptions? Why is there gold (19,300 kg/m^3) and iron in the Earth's crust... I suggest David Hammen's post.