Soap sinks or floats depending on its density, or the amount of mass in given volume. Soap that has air whipped into it has a lower density. It's the same principle as comparing a ceramic cup to a Styrofoam one. The latter cup floats because of its air bubbles.
The only commercial bar soap on the market as of 2015 that does float is Ivory. Created in 1863, this floating soap was rumored to be a production mistake. That argument is debatable, but Procter & Gamble Company turned the floatability factor into a marketing strategy. The soap was a hit because if it slipped out of a hand while bathing, it floated on the surface of the water, making it easier to find.
A popular experiment in grade school classrooms involves comparing different soaps to see which ones float. The bars are simply placed, one at a time, in a bowl of water. As expected, the Ivory bar is a "floater."
Variations of the experiment involve heating the bars of soap in a microwave before dropping them in the water. Since the application of heat makes the bars expand and grow slippery, they become less dense and when placed in water, they may float.