Bara bin Azib reported,

When fasting in Ramadan was first prescribed, people would not approach their wives for the whole of Ramadan, and some men were being unfaithful to themselves. So Allah revealed, "Allah knows that you were deceiving yourselves, so He has turned to you in forgiveness and pardoned you" [Baqarah 2:187].

Azami 4552

Sahih

عن البراء بن عازب قال

لما نزل صوم رمضان كانوا لا يقربون النساء رمضان كله، وكان رجال يخونون أنفسهم، فأنزل الله: {علم الله أنكم كنتم تختانون أنفسكم فتاب عليكم وعفا عنكم}.

الأعظمي 4552صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Fasting
Chapter
What is permitted and what is not permitted for the fasting person
Section
Concession regarding approaching women during the nights of Ramadan
Numbering
Jami al-Kamil 4552 (2nd edition)
Azami 4552