As already mentioned by others, you are misrepresenting the case. The question "why is there pain" cuite correctly does not make too much sense, and I doubt very many people will ask that in seriousness.
The proper question is: "Why is there suffering?"
Pain is useful and with or without evolution, it is rather obvious why it is there.
The big classical question is, why a supposedly benevolent god would create a situation where a sizeable proportion of mankind, apparantly undeservedly, suffer substantial and prolonged, both literal pain, but also sorrow, frustration, abuse, etc.