That was because during the month of Ramadan, once the Muslims had prayed the night prayer, women and food were forbidden to them until the same hour the following night. Then some of the Muslims took food and went to their wives during Ramadan after the night prayer, among them Umar bin Khattab, and they brought this complaint to the Messenger of Allah ﷺ. So Allah revealed, "Allah knows that you were deceiving yourselves, so He turned to you in forgiveness and pardoned you. So now go in unto them" [Baqarah 2:187], meaning have relations with them, "and eat and drink until the white thread becomes distinct to you from the black thread of dawn" [Baqarah 2:187].
في قوله تعالى: {أحل لكم ليلة الصيام الرفث إلى نسا إنكم}
ذلك أن المسلمين كانوا في شهر رمضان إذا صلوا العشاء حرم عليهم النساء والطعام إلى مثلها من القابلة، ثم إن أناسا من المسلمين أصابوا الطعام والنساء في رمضان بعد العشاء، منهم عمر بن الخطاب، فشكوا ذلك إلى رسول الله ﷺ فأنزل الله: {علم الله أنكم كنتم تختانون أنفسكم فتاب عليكم وعفا عنكم فالآن بشروهن} يعني: أنكحوهن {وكلوا واشربوا حتى يتبين لكم الخيط الأبيض من الخيط الأسود من الفجر}
Ibn Jareer Tabari (3/235–236) narrated it from Muthanna, who said, Abu Salih narrated to us, who said, Muawiya bin Salih narrated to us, from Ali bin Abu Talha, from Ibn Abbas, and he mentioned it. Its isnad is hasan because of Muawiya bin Salih, for his hadith is hasan.