The last of the Aseres HaDibros is the issur of lo sachmod, not to desire. The Shevet Mussar explains a person is unable attain anything which is not the ratzon Hashem. One can spend his whole life running after things he is not destined to attain. If it is decreed from Hashem he will attain it. With this thought a person can be happy with his situation and serve Hashem properly.
The Shevet Mussar adds a thought to make this sharper. One should think to himself: is it possible for a gnat to plow together with an ox? Can a fly become king over people? Would an ant fight a lion? Can an elephant be stuck in the eye of a needle? So too, it is not realistic to think that one can get something that is not meant for him.
A mashal to this is with a child who sees his shadow on the wall. He thinks to himself: if I send out my hand I will grab hold of it. He reaches out his hand to the shadow and there is nothing there. Time after time he tries to grab it; maybe he’ll be able to catch it. He does not realize that time will end before he has reached his goal. Similarly, if a person tries to reach something and doesn’t, he should think it is a decree from Shamayim. Why should I waste my time and years? It is better for me to be happy with what I have and with this I’ll be satisfied my whole life.
From the Gemara in Sotah we see yet another about improper desiring. If one looks for something which is not fitting for him, then not only doesn’t he attain it but he even loses that which he has. A mashal to this is a horse that is eating an apple by the water. He looks into the water and sees a horse eating an apple. The horse tries to grab the apple in the reflection and thereby loses the apple which was in his mouth.
May we be content and happy with our lot and remember that everything is from Hashem!