Why does pain hurt?

When you touch a hot stove, you reflexively pull your hand away in an instant....