Allow me to explain to you why that was an OT law: Firstly, it was to prevent that situation from happening in the first place. It deterred irresponsible young men who otherwise would have their cake and eaten it too. Secondly, in the rare instance that it did happen, it forced the perpetrator to suffer the consequences for his actions, such as helping raise the resulting child if there was one, providing food and shelter not only for himself but his wife and offspring also, and making sacrifices on behalf of his family. In conclusion, God, in His infinite wisdom, established a law that protected the basic building block of society, the family unit.