Anas bin Malik reported,

The Messenger of Allah ﷺ delivered a sermon unlike any I had ever heard. He said, "If you knew what I know, you would laugh little and weep much."The companions of the Messenger of Allah ﷺ covered their faces, weeping audibly.A man asked, "Who is my father?"He replied, "Your father is so-and-so."Then this verse was revealed, "Do not ask about things which, if revealed to you, would distress you" [Maidah 5:101].

Azami 1283

Sahih

عن أنس بن مالك، قال

خطب رسول الله ﷺ خطبة ما سمعت مثلها قط. فقال: لو تعلمون ما أعلم لضحكتم قليلا ولبكيتم كثيرا. قال: فغطى أصحاب رسول الله ﷺ وجوههم لهم حنين. فقال رجل: من أبي؟ قال: أبوك فلان فنزلت هذه الآية: {لا تسلوا عن أشياء إن تبد لكم تسؤكم}.

الأعظمي 1283صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Knowledge
Chapter
Warnings in matters of knowledge
Section
Prohibition of excessive questioning about what has not occurred and about which no revelation has been sent down
Numbering
Jami al-Kamil 1283 (2nd edition)