Permitted to you, on the night of the fasts, is the approach to your wives. They are your garments and ye are their garments. Allah knoweth what ye used to do secretly among yourselves; but He turned to you and forgave you; so now associate with them, and seek what Allah Hath ordained for you, and eat and drink, until the white thread of dawn appear to you distinct from its black thread; then complete your fast Till the night appears; but do not associate with your wives while ye are in retreat in the mosques. Those are Limits (set by) Allah: Approach not nigh thereto. Thus doth Allah make clear His Signs to men: that they may learn self-restraint.
Yahiya Emerick writes:
Background on the first half of verse 187:
When fasting was first introduced as a personal obligation, there was some confusion among the community in Medina about what was allowed for them to do after sunset. Some thought that no intimate relations were allowed after the last prayer of the day (‘isha). Others used mental gymnastics to justify having intimate relations when they really had misgivings about it. Yet, others were of the understanding that if a person slept after fast-breaking, all eating and such were forbidden for the rest of the night. When ‘Umar ibn al-Khattab (d. 644) complained one day about his confusion over the issue, this Qur’anic verse was revealed, clarifying that intimate contact between married people at any time of the night is allowed during the month of Ramadan. (Ibn Kathir)
Emerick, Yahiya. The Meaning of the Holy Qur’an in Today’s English (p. 77). Unknown. Kindle Edition.