It is narrated from Sayyiduna Abdullah bin Amr bin al-As (may Allah be pleased with them both) that the Messenger of Allah (peace and blessings of Allah be upon him) passed by two circles in his mosque and said: "Both are upon goodness, but one gathering is superior to the other. One group of people is supplicating and beseeching Allah Almighty; if He wills, He grants them, and if He wills, He withholds from them. The other group is learning knowledge and understanding of religion and teaching the ignorant, so they are superior. And I too have been sent as a teacher." The narrator said: Then he (the Prophet) also sat with them.
Related hadith on this topic