Pain hurts because it causes neural activity that causes you to step back quickly, be unable to go near the source of the pain anymore, not to want to, and to remember it for psychological reasons as "ouch, that (Stimuli Type 2868)ed, it felt really bad".