Abdullah bin Abdur Rahman narrated that the Messenger of Allah (peace be upon him) said: "Whoever acquires this knowledge (i.e., religious knowledge) to attain worldly gains, Allah, the Exalted, will make the fragrance of Paradise forbidden for him on the Day of Resurrection."
Brief Explanation
(Commentary on Hadith 261)
The meaning of this hadith is that whoever acquires religious knowledge (ilm al-din) for the sake of worldly gain, not only will he be deprived of entering Paradise, but he will not even smell its fragrance. Therefore, religious knowledge should be acquired purely for the sake of Allah (khālis-an li-wajhi-llāh). As it is mentioned in the hadith: «مَنْ تَعَلَّمَ عِلْمًا مِمَّا يُبْتَغَى بِهِ وَجْهُ اللَّهِ، لَا يَتَعَلَّمُهُ إِلَّا لِيُصِيبَ بِهِ عَرَضًا مِنَ الدُّنْيَا، لَمْ يَجِدْ عَرْفَ الْجَنَّةِ يَوْمَ الْقِيَامَةِ» [صحيح الجامع 60350] And glad tidings are given to the one who acquires knowledge for the pleasure of Allah: «﴿وَمَنْ يَتَّقِ اللّٰهَ يَجْعَلْ لَهُ مَخْرَجًا . وَيَرْزُقْهُ مِنْ حَيْثُ لَا يَحْتَسِبُ وَمَنْ يَتَوَكَّلْ عَلَى اللّٰهِ فَهُوَ حَسْبُهُ﴾ [الطلاق : 2 ، 3]» “Whoever fears Allah, He makes a way out for him and provides for him from where he does not expect. And whoever puts his trust in Allah, He is sufficient for him.”