Animals runway to escape whenever they experieced pain, especially when caused by other animals or fire. It is a fundamental advantage to those animals that feel pain than those animals that they don't feel pain.
Eventually, animals that experienced pain survived. Does it pain to plants? I don't know.
However there are theories that suggest that pain is a glitch in the evolution and pain doesn't really help us. But I disagree with this theory since, there are milliions of species of less brainy animals that can't think like humans and take decisions to stay away from enimies.
Even, it is not difficult to images what happens to a person who doesn't experience pain. The answer is he would get injured very often and he wouldn't know most of the times, what the cause is for the injury. Thus, he/she loses the advantage of survival.