A toilet that rocks back and forth can be unsanitary. Leaking will occur from the toilet gasket as the toilet rocks back and forth. If it is not fixed the toilet itself can be damaged beyond repair. Worse, a leaking toilet at the gasket will degrade the floor around the toilet and eventually the floor will need to be replaced. This is something a person with solid do it yourself experience will be able to accomplish. Follow these steps to fix a rocking toilet.
Inspect the floor around the toilet. If the floor is wet check for leaks at the water connections and between the bowl and tank. If no leaks are found, flush the toilet a few times. Look for moisture coming from underneath. If the water is coming from under the toilet then the wax ring will need to be replaced first. This will entail removing the flange bolts, pulling the toilet up, scraping the old wax ring away and putting down a new one.
Tighten the flange nuts. These are the nuts on the sides under the plastic caps. The nuts need to be snug. Do not over tighten them because that will break the base. The purpose of these nuts is to hold the toilet in place, not to keep it from rocking.
Level the toilet bowl. Place shims between the bowl and the floor. Press the shims in as far as they will go so that they do not protrude outside of the toilet base. This will stop it from rocking. Sit on the seat to make sure. Make tightening adjustments now.
Caulk the toilet base with a caulk gun and latex tub and tile caulk. The caulk does two things, It firstly will make a watertight seal between the toilet bowl base and the floor, and secondly, it will cover up the shims to make the base look aesthetically good.
Wipe all excess caulk off of the toilet. Make sure you do not remove too much. Use your finger to form a nice even bead all the way around. Do not use the toilet until the caulk has dried.