I think there is a bit of a logical leap here (or at least in the title).
The simple answer is that there are many biological phenomena for which there is no logically satisfactory explanation. For instance: why do people have wisdom teeth? We come up with some hand-wavy explanations about ancestral diets, but at the end of the day we just have wisdom teeth (or at least most of us do) and there isn't a great immediate causal pathway that tells us why this rather inconvenient thing exists in modern humans and hasn't been lost.
Getting back to the question at hand, there are a number of assumptions that seem to come along with this question:
- Most importantly, why is it assumed that there must be an evolutionary "reason" for a biological phenomenon? In many/most cases there is no such reason. Most (molecular) evolution is neutral and random.
- Why is it assumed that there is an equivalence between tickling and sexual stimulation? (then again, a cursory google search suggests there is a relationship...)
Both tickling and masturbation are phenomena that seem to occur in primates. However, this does not require that there be a link between them even if they appear to be similar superficially. Furthermore, it is not logically required that either of them satisfy any particular purpose, even if we can imagine a possible purpose (as some of the commenters have).
Of course, there are lots of reasons why these things exist if you're willing to drop the evolutionary mumbo-jumbo. For instance: both of these things can be fun and God loves us and wants us to be happy. This is the same as the platitude from Ben Franklin on why booze exists. Substitute your favorite demiurge.
These arguments are not much different from arguing that constant ejaculation leads to better sperm on evolutionary time scales. There is equally good (better?) evidence that having to produce more sperm leads to a higher prevalence of birth defects and other disorders. So maybe masturbation is bad from one reasonable point of view, and is in fact a deleterious vestigium like wisdom teeth. The "scientific" answer depends a bit on which literature you pay attention to.
Evolutionary answers of this type tend to be this kind of just-so stories. They give an air of precision and authority with uncertain logical backing, and they don't even have the folksy philosophy as a consolation.
This may not be an answer in the fashion the OP intended, but hopefully it does at least give a perspective on thinking about these kinds of questions.