Abdullah ibn Mas’ud reported: The Prophet, peace and blessings be upon him, said:
لَا حَسَدَ إِلَّا فِي اثْنَتَيْنِ رَجُلٌ آتَاهُ اللَّهُ مَالًا فَسُلِّطَ عَلَى هَلَكَتِهِ فِي الْحَقِّ وَرَجُلٌ آتَاهُ اللَّهُ الْحِكْمَةَ فَهُوَ يَقْضِي بِهَا وَيُعَلِّمُهَا
There is no envy but in two cases: a man whom Allah has given wealth and he spends it rightly, and a man whom Allah has given wisdom and he judges and teaches with it.
Source: Ṣaḥīḥ al-Bukhārī 73, Grade: Muttafaqun Alayhi