The somatosensory system allows us to experience touch, pain, pressure, heat and movement. This system relies on a network of sensors throughout the body, which are activated when there is heat or pressure against them.
So that your body knows what is going on at different areas, these sensors send information back to the brain by means of neurons. In turn, these send signals up the spinal cord to the brain.
Once there, the brain decodes the messages to understand what sensations are being felt: pain, touch or temperature.