Originally Posted By: olly

Without getting to biblically inclined it was, as zmjezhd pointed out, technically a Levirate marriage which was legal. It was indeed the spilling of the seed for his own means that was the crime.

Correct. A Levirate marriage maintained the line of the brother and his share in the national "salvation" - ie his right to a bit of the Promised Land. The children born would be counted as those of the dead brother not the living one, and that's why Onan "spilled his seed" - because those children would've competed with his own for the family resources.