An Ansar of Medina came to the Holy Prophet (s) looking perturbed. He voiced his bewilderment thus: ‘Ya Rasool Allah (s), if there is a funeral ready for burial and a lecture is being delivered on teaching a useful skill simultaneously, and I can attend only one, which of the two has a greater right on my attendance?’
‘If there are people to bury the dead, you must attend the lecture that increases your knowledge, because the reward of one such lecture is better than attending 1000 funerals, visiting 1000 patients, 1000 nights of prayer, 1000 days of fasting, 1000 dirhams given in charity, 1000 non-obligatory Hajj, and 1000 non-obligatory jihad.
There is a world of difference between all the above and one session spent in a scholar’s company. Do you not know that only knowledge leads you to worship God, and only knowledge teaches you how to worship God? The good of this world and the next is aligned with knowledge, just as the evil in this world and the next is aligned with ignorance.’
Reference : Anecdotes of The Ahlul Bayt (Daastaan e Raastaan ) by Ayatullah Murtadha Mutahhari