Where does the Torah forbid “wasting seed”?
The most authoritative work of Jewish law, the Shulchan Aruch (Even Ha’ezer ch. 23), states categorically that
“it is forbidden to release semen for no purpose and this is as serious a sin as any in the Torah…those who masturbate…and release semen, not only is it a serious sin…but it is as though they’ve killed a human being.”
This passage is directly based on many passages in the Talmud*. As far as any health benefits the practice might generate, I would be skeptical. I’m not a doctor, but I do know that, if you monitor science-oriented news releases for about six months, you will probably hear of studies claiming that just about every food and activity is both healthful and deadly. I’d say that halacha is more important than applying questionable science in a questionable way.
However, as a general observation, it must be said that masturbation is also a Jewish law like any other Jewish law: while it must be observed, it is recognized that it was given to human beings who can fall prey to normal, human failings. If we were all able to perfectly observe every commandment of the Torah, there really would be no purpose in the exercise as we’d all be “there” before we start. Just like school is for imperfect, immature students (perfect children would be wasting their time there, wouldn’t they?), so the Torah was given to real, imperfect Jews.
What’s important is that a person should try to improve (and when we perfect one area, we move on to another, more difficult problem). As long as someone’s making a good effort and, from time to time, can claim some successes, he can say he’s trying to live up to Torah morality and he has a right to join the “fraternity” of conscientious Jews.
*[The source for the prohibition of wasting seed is Talmud Niddah 13b, where it is derived from the sixth Commandment (Lo Tin’af); see Rif Shabbos Ch.14 (p.78 in the standard editions) and Rashi on it. The subject is treated in Maimonides’ code in Issurei Biah 21:18, and in Shulchan Aruch Even ha-Ezer 23:1. See also Talmud Yevamos 34b, particularly on the sin of Er snd Onan (Gen. 38:7-10).]