Since there are hundreds of nails, instead of puncturing your skin the nails actually support you.
Explanation:
If you step on the point of a nail, your foot exerts a tremendous amount of pressure on the nail's tiny point. As a result, the point can go straight through your foot. But a bed of nails has lots of points that are close together -- there's a lot of surface area for the body to cover. Hundreds of nails support the weight of your body instead of just one. Typically, your body doesn't exert enough pressure on any one nail for it to break the skin. You can even place a second bed on top of you and break a cinderblock on it. The resulting force is distributed over all of the nails, so you shouldn't be injured.