Usually, you feel this familiar sensation after you've been putting pressure on part of your body -- sitting on a foot, sleeping on an arm, etc. When you apply this pressure for a prolonged period of time, you actually cut off communication from your brain to parts of your body. The pressure squeezes nerve pathways so that the nerves can't transmit electrochemical impulses properly. Nerve impulses carry sensation information from nerve endings in the body to the brain, as well as instructions from the brain to the parts of the body. When you interfere with this transfer by squeezing the nerve pathways, you don't have full feeling in that body part, and your brain has trouble telling the body part what to do.
This pressure can also squeeze arteries, stopping them from carrying nutrients to body cells. Without these nutrients, the nerve cells may behave abnormally, which can further interfere with communicating bodily sensations.
Due to both these factors, the information transmitted from the body part becomes somewhat jumbled, and the brain receives strange messages. Some nerve cells don't transmit any information and others start sending impulses erratically. This causes you to feel a strange tingling sensation, which actually serves an important function. Your foot falling asleep for 10 minutes doesn't pose any health threat, but if you were to cut off circulation for an extended period of time -- several hours -- you could suffer serious nerve damage. The initial tingling sensation tells you that you might want to readjust your position.
Once you do move your foot, stretch your legs, or roll over off your arm, the nerve impulses begin to flow properly again. You don't regain feeling right away, however. There is a certain amount of re-adjustment time before the nerves transmit impulses correctly again. This increases the intensity of the tingling, causing the familiar "pins and needles" sensation.
If this has ever happened to you, you know that there are actually a few distinct sensations you go through as your body part "wakes up." The tingling may be followed by a more uncomfortable burning sensation, before your body part finally returns to normal. This happens because the nerves in your body are made up of separate long nerve cells that carry different sorts of impulses. These nerve fibers have different surrounding structures. Some nerve fibers have thicker "insulation" around them and so take longer to begin transmitting impulses properly after they've been squeezed. The fibers that transmit pain and temperature information are relatively thin, so you feel the tingling situations pretty quickly. Motor control fibers are thinner than the ones carrying touch information, so you can move the body part before you've regained complete feeling in it. Eventually, all the nerve fibers return to normal and you regain full use of the sleeping body part.