A clay bar is a specially designed resin compound which is similar in texture to "play dough". Used with the correct clay lube, the clay bar glides over the paint to gently remove anything protruding the surface. Clay bars usually come in 2 forms. Medium and hard. Depending on the condition of the paintwork, either can be used to great effect. Your paintwork can harbor many different kinds of contaminant. This can be in the form industrial fallout (commonly given off from rail lines) brake dust, tree sap and tar. These can pierce the paintwork and can only be removed by clay barring. Polishing by hand and even machine polishing can miss these contaminants.
Below you will see diagrams illustrating this point and what a clay bar does to remove them.