There is the famous hadith about Ghibtah,
عن ابن عمر رضى الله عنهما قال : قال رسول الله صلى الله عليه وسلم : (لا حسد إلا في اثنتين : رجل آتاه الله القرآن فهو يتلوه آناء الليل وآناء النهار ورجل آتاه الله مالاً فهو ينفقه آناء الليل وآناء النهار). (البخاري ومسلم)
Ibn 'Umar radhiyAllahu ‘anhuma reported that the Prophet sallallahu ‘alaihi wa sallam said,
"Envy is allowed in two cases, in case of a man whom Allah has given the Qur'aan and who recites it throughout night and day; and a man on whom Allah has bestowed wealth who gives it away throughout night and day."
[Sahih al-Bukhari and Sahih Muslim]
Scholars have emphasised the distinction between "Ghibtah" and "Hasad".
Al-Ghibtah means to have the desire to achieve the good qualities that others have. Al-Ghibtah is a positive behavior which motivates you to do good, as good as other people do.
For example, when you see a knowledgeable person, you admire and wish to be knowledgeable like him; when you see someone who do a lot of ibadah, you wish to do the same; when you see a rich person who pays charity, you admire him and wish to be like him.
So you admire these people for their good actions and hence you wish to be like them.
Al-Ghibtah, then, is actually good and desirable. It influences our attitude and behavior in a positive way.
Al-Hasad, on the other hand, means 'envy'. It is a negative behavior which is prohibited and condemned in Islam. The Prophet, sallallahu alayhi wasallam, said that al-Hasad demolishes the rewards.
It is envy and jealousy that occurs when you see someone who is given some privileges that you do not have.
It is Allah who gives His Bounty to anyone He choses. So we should not feel any objection to Allah's plan.
That is why al-Hasad is considered a very bad behavior and a major sin.