Apes do it, dogs and cats do it, elephants do it and even porcupines have been observed doing it, probably very carefully. One reason we may be so programmed, paradoxically, is to increase our odds of producing offspring. Older sperm can lose their ability to swim well. A good masturbatory flush guarantees fresh, robust sperm for mating. Storing seminal fluids for long periods can also cause prostate congestion, which in turn can lead to urinary and ejaculatory pain.
Masturbation is also an ever-renewable health resource.
In fact, the people who start the earliest and do it the most often are the ones who do it longest into old age. This is especially true in females where strong PC muscles are practically the sole factor in whether labor is easy and fast or long and difficult. Females masturbating regularly with multiple orgasms would develop strong PC muscles and should have easier labor. Another potential concern is reliance on masturbation for sexual pleasure to the exclusion of intimacy with another person. But in such cases, masturbation is probably a symptom, not a cause, of larger psychological barriers to intimacy.