Anyway, I think the ultimate rationale is that the Church (and many, if not most, other organized religions) is just opposed to anything that feels good, and masturbation tops that list. There's some bit in the Old Testament somewhere where some guy is commanded by God to impregnate some woman, but at the last minute he "spills his seed on the ground," and is struck down by God. This is generally viewed as the scriptural basis for the anti-masturbation rule, but it always seemed to me to be more a matter of disobeying God's direct order to knock up the girl than anything having to do with masturbation per se. But apparently, drunken sex with one's daughters is fine and dandy, whereas taking matters into one's own hand is not.
That would be Mr. Onan. No one ever liked Mr. Onan anyway. He smelled funny.
Mr. Onan's is actually, especially in its full context, one of the most bizarre stories in the bizarre volume that is the Bible.
Judah, oldest son of Jacob, marries and fathers three sons: Er, Onan, and Shelah. In the fullness of time, he buys a bride for Er, named Tamar.
For no reason that's made clear in the text, God gets angry with Er and kills him. Law and custom mandate that Onan now father a child on Tamar: this child will legally be the eldest son's offspring, and thus inherit the eldest son's large portion of the family inheritance. (If Er had died unmarried, this extra helping would presumably have defaulted to Onan.)
For whatever reason, Onan doesn't want to. Maybe he was hoping to have something to leave to his own kids. Maybe he just doesn't like Tamar. Anyway, he "spills it upon the ground" -- this is usually taken to mean he practices withdrawal. God gets mad at him for refusing to father a child that won't be his, and kills him too.
The only son left is Shelah, and he's too young yet for marriage. But Tamar is the family daughter-in-law, bought and paid for, so she has to hang around until Shelah's old enough. But in a while she notices that Shelah
is getting to be "old enough" and Judah shows no sign of pairing his last son off with this bad-luck woman.
After a while, Judah's nameless wife (she is only ever referred to as "the daughter of Shuah") dies. After his first grief is over, Judah and his friend Hirah go up to Timnath for the sheep-shearing. Tamar hears about it: she takes off her widow suit, dresses herself as a wh0re with a veil over her face, and goes and sits by the road to Timnath. Judah doesn't recognize her, and negotiates with her, eventually arriving at the price of a goat for a f[rule8]. She agrees, but demands an IOU in the form of his staff and his family signet and bracelets. He hands them over and they do the dirty deed. He goes his way, and she puts her widow suit back on and goes back to her demure widow's lifestyle.
Judah, after he gets home, sends his buddy Hirah to drop off the goat and redeem the IOU. Hirah comes back leading the goat, explaining that not only couldn't he find any wh0re along there, but everybody in the area says there never
was any wh0re there! Oh crap, thinks Judah, that's what I get for letting a woman get her hands on the family jewels. But he keeps his mouth shut, to avoid public embarrassment.
Oh, boy.
Three months later, Tamar turns up pregnant. Judah hears about it: "Your daughter-in-law has been slutting around, and she's pregnant from it." His response is unhesitating: "Bring her out and let her be burned!" (Not a syllable about waiting until she gives birth. Burn her right now, fetus and all. Hey, pro-lifers? Dig this.)
Tamar comes out in her widow's weeds and burgeoning bump, and drops Judah's staff and bracelets and signet at his feet. "Perhaps you can tell me whose these are?" she says.
Talk about public embarrassment. Judah has to admit: he was in the wrong here, since he refused to give her to Shelah. He doesn't have sex with her any more, but neither is it recorded that he gives her to Shelah: it's not necessary now that she's pregnant. Tamar gives birth to twins, biologically Judah's offspring but legally his grandchildren, and nothing more is heard of her. She's accomplished her task and produced an heir.
That, after all, is what women are
for.