The Messenger of Allah ﷺ had a slave-girl with whom he was intimate. Ayesha and Hafsa kept pressing him about her until he forbade her to himself. So Allah revealed, "Prophet, why do you forbid yourself what Allah has made lawful for you?" [Tahrim 66:1] to the end of the verse.
أخبرني إبراهيم بن يونس بن محمد حرمي هو لقبه قال حدثنا أبي قال حدثنا حماد بن سلمة عن ثابت
أن رسول الله ﷺ كانت له أمة يطؤها فلم تزل به عائشة وحفصة حتى حرمها على نفسه فأنزل الله عز وجل {يا أيها النبي لم تحرم ما أحل الله لك} إلى آخر الآية
[Its chain of transmission is sahih]. It is in al-Kubra, no. 8907, and the Haafiz declared it sahih in Fath al-Bari: 9/376. Hakim also narrated it in 2/493 through the route of Sulayman bin Mughira from Thabit, and declared it sahih according to the criterion of Muslim, and Dhahabi agreed with him.