That misses a key point. This wasn't just any coupling. From this union, came the tribe of Judah, from whom the Jews are descended.
In other words, Onan's act almost prevented the line from which the Messiah will come (or has come, if you are Christian). That was the crime worthy of the severe penalty.
marking
"Onan's act almost prevented the line from which the Messiah will come (or has come, if you are Christian). That was the crime worthy of the severe penalty."
Onan didn't know about that, and so his crime was no better or worse than any other person who either (A)Practiced onanism or (B)Failed to perform his levirate duty. If all he were guilty of were (B), then he only merited the quite mild punishment presribed in Deut. 25.
Historically, Christians have always identified his crime as onanism -- until the 20th Century Protestant contraceptors came along and re-interpreted the passage to make it comatible with the recently invented Protestant doctrine endorsing contraception.