"Their marriage can radiate a fruitfulness of charity, of hospitality, and of sacrifice.”
So if the Catholic Church teaches us that sex is mainly for procreation, what happens if one of the spouses in the marriage is unable to conceive children, or what happens to the sex life of a married couple once they pass the childbearing years?
When you ask what happens in the case of infertile married couples, in regard to their marriage and intimacy, my short answer would be: Nothing really. In the eyes of the Church, they still can be faithfully married to each other and, as long as they are physically able and willing, have an active sex life just like any other married couple. The Catholic Church has sympathy for couples suffering the cross of infertility, and the Church certainly doesn’t punish infertile couples by forcing them to live as celibates or invalidate their marriage.
“Sterility neither prohibits nor nullifies marriage” (Canon 1084.3)
This is at least in part because what you set up as the premise of your question — “So if the Catholic Church teaches us that sex is mainly for procreation” — is not wholly accurate.
Married sex is the physical culmination of married love and brings couples together, not just fulfilling physical needs and desires, but bonding them emotionally and providing comfort. It is a unique experience shared between spouses and is so much more than just the duty of childbearing or the quenching of lust. The Church actually recognizes the emotional need for physical intimacy between spouses even if their union can’t or doesn’t result in children due to age, illness, infertility, or injury. That said, couples cannot purposefully render their physical union sterile.
Pope Paul VI stated, “The sexual activity, in which husband and wife are intimately and chastely united with one another, through which human life is transmitted, is, as the recent Council recalled, ‘noble and worthy.’ It does not, moreover, cease to be legitimate even when, for reasons independent of their will, it is foreseen to be infertile. For its natural adaptation to the expression and strengthening of the union of husband and wife is not thereby suppressed.” (Humanae Vitae, n. 11, bold emphasis mine)
I also like the way the Catechism of the Catholic Church beautifully emphasizes that married spouses who are infertile can still have fruitful and prosperous marriages.
[CCC 1654] “Spouses to whom God has not granted children can nevertheless have a conjugal life full of meaning, in both human and Christian terms. Their marriage can radiate a fruitfulness of charity, of hospitality, and of sacrifice.”
Infertility can be exceptionally painful for spouses who desire children, and we must minister to them with kindness and charity. Nevertheless, within the sacrament of marriage, sex is still “noble and worthy” and important for the strengthening of their union. We would not deny married couples this expression of love simply because they are not able to bear children as a result. The Church knows this and that is why She has gone through such pains to emphasize the importance of sexual intimacy for the betterment of married couples.