I think that this is the same thing as jealousy and envy,.. but my question is that why is it a sin? If you're jealous that somebody has something that you want or got to do something that you really wanted to do,.. who exactly is that hurting? In the first case scenario it's not like you're stealing anything from them or anything.
Sin shouldn't be defined simply as "something that hurts other people". That's the world's definition of sin. But we know that sin is also an offence against God. It
includes things that harm other people, but there's a lot more to it than that. Sin can - and does - happen inside our heads, as Jesus taught in the Sermon on the Mount
(Matthew 5:21,22 & 27,28). This is why coveting is a sin, just like hatred and greed.
As to jealousy and envy: I don't think they are quite the same. Jealousy can be legitimate; envy is always bad. Not primarily because it harms other people (although it can lead to actions that do harm) but because it harms
you.
Envy looks at someone else and says, “I want what they have” (which could be a possession, a talent, or a personal quality). And rather than channel that desire into positive action (such as working harder in order to achieve that goal or acquire that skill for ourselves), envy turns our thoughts inward and makes us feel bitter and resentful. “It’s not fair,” is Envy’s motto.
Envy distorts the way in which we view the world. It focuses our attention on what we don’t have, so that we are no longer grateful for what we do have. It drives us to be continually comparing ourselves with others - which is guaranteed to take away our inner joy and our peace of mind! It destroys our friendships. It can even persuade us that we are justified in harming the object of our envy. And in the end, it is self-destructive - it does more harm to me than to anyone else
(Proverbs 14:30).
And envy is also a sin against God! It's a symptom of unbelief, because it refuses to find contentment in God and in what He chooses to give us.