In Exodus 20:5, it is not that God is jealous or envious because someone has something He wants or needs. Thou shalt not bow down thyself to them, nor serve them: for I the Lord thy God am a jealous God, visiting the iniquity of the fathers upon the children unto the third and fourth generation of them that hate me;
Notice that God is jealous when someone gives to another something that rightly belongs to Him.
God is rightly jealous when worship, praise, honor, or adoration is given to idols.
For I am jealous over you with godly jealousy: for I have espoused you to one husband, that I may present you as a chaste virgin to Christ. -2 Corinthians 11:2