Nerves are like electric wires. They carry a signal that tells you when something hurts. This signal goes from your body to your brain. It is in the brain that this signal becomes the feeling of pain.
The spinal cord is like a switch or a traffic light. It can slow down or block some pain signals, which helps you feel less pain.