All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
Competition in learning and fulfilling the acts of worship is something highly praised by Allaah, The Almighty, Who says (what means): {…so race to [all that is] good…} [Quran 5:48]
It is not included in the dispraise stated in the Hadeeth; rather, the one who is dispraised is the one who only seeks a noble status in this life and worldly benefits. Abu Hurayrah narrated that the Messenger of Allaah, sallallaahu ‘alayhi wa sallam, said: “Whoever acquires knowledge which should be sought for the Sake of Allaah, but he only learns it in order to attain some worldly goal, he will not smell the fragrance of Paradise on the Day of Resurrection.” [Abu Daawood, Ibn Maajah and Ahmad - Al-Albaani graded it Saheeh (sound)]
Abul Hasan Al-Mubaarakfoori said: “It means that he does not learn it for any other reason than to attain worldly pleasures. It indicates that the stated threat is for the one who seeks nothing from knowledge except the worldly benefit. However, this threat does not apply to the one who seeks with his knowledge the pleasure of his Lord and along with that he has inclination to a worldly benefit. Seeking the Pleasure of Allaah, The Almighty, has to come first and the worldly benefit comes after it.” [Mirqaat Al-Mafaateeh Sharh Mishkaat Al-Masaabeeh 1/326]
It is worth noting that the knowledge stated in the Hadeeth refers to religious knowldge. As for the worldly sciences such as mathematics, medicine, and engineering, there is no blame learning them and competing in them to get a job, wealth or status.
Shaykh Ibn ‘Uthaymeen said in Sharh Riyaadh As-Saaliheen: “There is nothing wrong with seeking a worldly benefit through worldly knowledge. One may learn engineering to be an engineer to get a salary. Another one may learn mechanics to be a mechanic who works and strives for worldly benefits. There is no blame on that person to seek the worldly life from his learning. However, if he intends to benefit Muslims with what he learns, this will be better for him; for he will attain by that benefits for his worldly life and afterlife.”
Allaah Knows best.