Abdullah ibn Mas’ud reported: The Prophet, peace and blessings be upon him, said,
“There is no envy except in two cases: a man whom Allah has given wealth and he spends it according to its right, and a man whom Allah has given wisdom and he judges and teaches with it.”
Source: Sahih Bukhari 73