This verse combats a very human temptation: looking at the apparent "success" of those who do not follow God's rules and feeling like we are missing out on something.
The Poison
"Do not let your heart envy sinners": Envy is an emotional cancer. It does not change the other person's reality, but it rots our own. When we envy someone who prospers by doing evil, we are, deep down, questioning God's justice and devaluing our own path. Envy pulls our focus away from our mission and puts it on someone else's life.
The Antidote
"always be zealous for the fear of the Lord": The cure for horizontal comparison (looking sideways) is vertical focus (looking up). The "fear of the Lord" is that ongoing reverence, the certainty that God is the final judge and that His way is best, even when the "sinner's" path seems easier for the moment.
The Constancy
The Hebrew idea behind "always" is not a battle won once. The temptation to compare knocks on the door daily (on social media, at work). The decision to "fear the Lord" (to respect Him and trust Him) also needs to be daily.
"The Root of Rejection" — Joyce Meyer
Envy is often a symptom of the root of rejection. When we are not secure in our worth and our acceptance in God, we look at what others have as a measure of our own worth. If I feel rejected, the neighbor's grass will always look greener. Healing from rejection removes the need for envy, because we know we have exactly what we need in the Father.
"The Knight in Rusty Armor" — Robert Fisher
The Knight lived comparing himself to other knights in distant kingdoms. He wanted to have the shiniest armor. That outward pursuit (envy, comparison) only reinforced his prison. He only began to be set free when he stopped looking outward and started looking inward and upward.
Jesus never envied Pilate's power, Herod's wealth, or the influence of the Pharisees. He knew that their "success" was fleeting and that His Kingdom was not of this world.
He kept His focus perfectly on the Father: "I always do what pleases him" (John 8:29).
As Christians, our inheritance in Christ is eternal and infinitely superior to any momentary pleasure that sin could offer. When we understand the value of what we already have in Him, envy loses its meaning.