The 'secret' to this phenomenon is first to understand that it is the force per unit area of skin (i.e., pressure) that determines if a nail will pierce the skin
If there were only one nail, the entire force created by the weight of the body would be distributed over the very small area presented by the tip of the one nail
However, when a 'bed' of nails is used, the same force produced by the weight of the body is distributed over perhaps hundreds of nails. Therefore, the force applied to any one nail is correspondingly reduced, with the result that the force per unit area at the tip of any one nail will (one intends) be well below the level required to pierce the skin