www.answers.com/topic/onan
Most information I find on this says that Onan did not want to raise a child of his as his brothers, I can understand that.
The above site suggests the interesting thing about this is that the law was not given till about 200-300 years after Onan.