Riyad as-Salihin, Book 13, Hadith 1376 (In-Book)

Mu'awiyah (May Allah be pleased with him) reported: The Messenger of Allah said, "When Allah wishes good for someone, He bestows upon him the understanding of Deen."[Al-Bukhari and Muslim].

وعن معاوية رضي الله عنه قال‏:‏ قال رسول الله صلى الله عليه وسلم ‏:‏ ‏ "‏من يرد الله به خيرًا يفقه في الدين‏" ‏ ‏(‏‏(‏متفق عليه‏)‏‏)‏

sunnah.com