The Family: A Proclamation to the World states:
The first commandment that God gave to Adam and Eve pertained to their potential for parenthood as husband and wife. We declare that God’s commandment for His children to multiply and replenish the earth remains in force.
This has been the constant aspect of parental responsibility despite changing social trends and means of contraception. The church continues today to counsel against elective operations that would induce permanent sterility as well as against elective postponement of child-bearing and rearing without good cause before the Lord, while recognizing that for medical reasons and to respect the propriety between couples, the decision of when to have children and how to space them is left between them and the Lord.
My personal view is that contraception equals "people prevention" and is contrary to the Lord's commandment when used as such. However, there are also medical and physical realities as well as questions of faith that can affect the ideal timing. Given the account of Abraham and Sarah, we recognize that the fulfillment of the Lord's promises as well as the capacity of couples to receive children in this life can vary significantly.
In order for God's plan for the happiness of His children to be sustained, we recognize the extremely damaging effect out-of-wedlock births and intimacy have on children and parents alike:
Children are entitled to birth within the bonds of matrimony, and to be reared by a father and a mother who honor marital vows with complete fidelity.
The integrity of the family unit is a key. Elective abortions are also counseled very strongly against in the church. All life-preserving options are highly preferred, including adoption into intact families.
I have a different personal perspective about Onan. The account of Onan is not limited to levirate duties. Even though his brother Er was a wicked man, the Lord commanded Onan to raise up seed unto his brother, ostensibly also so that his father's lineage would not die out. It is not specified what Er's wickedness was. Children honor their parents by having children of their own, and bringing them up in light and truth. Failure to honor one's parents and failure to multiply and replenish the Earth within honorable marriage are grounds for cursing. This is corroborated for example in Exodus 4 of the Lord seeking to slay Moses if he did not fulfill the law to rear up circumcised posterity for Israel. In so saying I recognize that not everyone has the blessing of an intact marriage in this life, regardless of how worthy or personally prepared they might be for it. If anyone is persecuted for inability to have children in such a context through no fault of their own, those doing the persecuting may be heaping up afflictions on the likes of Abraham and Sarah, whom the Lord blessed beyond measure.