It’s not the out of wedlock births that are the problem, it’s the fornication. God designed it to be a plague.
How can you have out-of-wedlock births without fornication, barring the death of a legitimate husband/father prior to the baby’s birth? Aside from that one special case, the one and the other are the same thing. All sin results in plague conditions.