You have something called pain receptors (nociceptors) in your skin that is connected to a nerve in your body. The nerve is then connected to the other nerves then to the spinal cord which is further connected to the brain in a specific part responsible for physical sensation. So when hurt the receptor will do the relaying of information to that part hence the pain. People have been trying to play around with this system to see if pain feeling could be stopped. Wouldnt it be nice?