On an insects head, the exoskeleton's plates are sealed together to protected the insect's brain.
An insect's brain isn't near as big as a humans or as complicated. But still, it's a brain and all brains are complicated.
The insects brain works a lot lick a humans' brain. It sends messages through the insects nerve cord and the insect reacts.
(A humans nerve cord is protected by a back bone)
The biggest questions is, dose a insect feel pain?
No one is quite sure but studies have shown that the insect probably doesn't feel any pain because if it did it would stop walking or at lease react somewhat.