You will need:
A bed of nails works on pressure.
Weight is evenly spread out across many nails, thereby reducing the chance of nails puncturing the skin.
If you sat on just one nail (or a a few), most of your mass would be concentrated on less surface area and the leverage of the sharp points would make the nails pierce you skin.
Moral of the story; it's a science experiment disguised as a "magic" trick... however, those nails are still sharp and if setup incorrectly you could hurt yourself or others so this experiment is not recommended to be replicated.