It is narrated from Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "Whomever Allah intends good for, He grants him understanding of the religion."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 10407