With Respect to Divorce - Divorce, per se, is not immoral. To set the proper tone to this answer you need to understand one important issue. The Sacrament of Marriage is not a LEGAL bond: it is a sacramental bond. Granted when two people marry they do enter into a legal contract (license) and the Church does recognize that legal contract but only insofar as property and personal rights are concerned. If you are divorced but wish to marry in the Church, you must first have your prior marriage investigated (annulment process). The Church will make a determination from the fact findings as to whether a sacrament was conferred. If the determination is that a sacrament was conferred then you are married to that person for life whether legally divorced or not.
As for married couples who are sterile having sexual intercourse, there are no prohibitions involved. If people can’t have children, then then can’t have children. Part of the cooperative responsibilties of the parties is to love and nuture each other. As to how the individual(s) became sterile may be more in line with your initial question. However, if this was a manmade act, the sterilization would be the sin and not necessarily the union of the two.
As long as you are in command of your free will and following God’s Will in cooperation with your partner’s Free Will, you are cooperating with God’s Plan. There is no sin in God’s Plan.