The princess and the peasant
לא תחמד אשת רעך ועבדו ואמתו ושורו וחמרו וכל אשר לרעך
Don’t covet the wife of your friend, his servant, his maidservant, his ox, his donkey, or anything that belongs to your friend
Many people have found the final of the Ten Commandments very hard to comprehend. People naturally have desires for things they see that attract them. If someone sees their friend in possession of a nice object, how could Hashem forbid them from wanting it? This is something that happens automatically, how can anyone be expected to avoid these desires?
The answer can be understood from a parable. Imagine a village peasant. He works in the fields, makes a little money, and lives a normal life. One day he sees the daughter of the King, and notices she’s incredibly beautiful. Do you think he has the slightest impression he has any possibility marrying her? If we asked him, he would admit his attraction, but it’s obvious to him that she’s from another world. He’s a lowly peasant, and she’s the princess of the kingdom. She has very different standards than him; different worldviews. She’s used to an entirely different reality. No plan he could come up with would convince her to marry him, so he doesn’t even consider trying. It’s crystal-clear to him.
The same is true with us. Once a person realizes that everything in life comes from Hashem, he’ll realize that no amount of plans or strategies will help him receive that which was not given to him. Hashem gives each person only that which they need, and nothing else. If I see my friend has something I want, I just need to think: he has it because Hashem knows it’s what he needs, and I don’t have it because Hashem knows it’s not what I need. Similar to the princess, his object is entirely removed from me. It’s in a different world. Therefore there’s no point in desiring it, because nothing I do or think will make it something I myself need. Once this concept is internalized, a person would then be happy with his portion, knowing Hashem gave him exactly what he needs. They will have faith that Hashem will provide them what they need, and thus do what is proper in His eyes.
It’s also clear why “don’t covet” is the final of the Ten Commandments. First Hashem gave specific commandments: don’t steal, don’t murder, don’t worship idols, etc. He then gave a general commandment at the end, which includes the other commandments. If a person observes the final commandment, they’ll then automatically end up observing the rest. This is because it’s clear that many transgressions come from coveting that which belongs to others. A person’s desires could be so strong they’ll end up stealing, or worse, killing.
However, even with this understanding, how can a person protect themselves from this transgression? Many times this desire comes on its own, without warning. What is the purpose of warning us against something that comes automatically? The answer is that the mitzvah is to work on ourselves; to build this concept into our minds. With continuous contemplation, it’ll become so clear that we have everything we need. Subsequently, these desires will no longer invade our minds. This is what we’re commanded.
 Based on Ibn Ezra to Exodus 20:14
 It’s interesting to note that the Rambam in Mishneh Torah Hilchos G’neivah V’Aveida 1:9 says a person doesn’t transgress לא תחמד by simply desiring another’s property (in § 10 he says that that’s the prohibition of לא תתאוה, listed in the second set of Ten Commandments in Deuteronomy 5:18). Rather, only once the person takes action to retrieve the item, for example by forcefully buying it, do they transgress. Either way, this desire is problematic
 Thus fulfilling the maxim in Avos 4:1: Who is rich? He who is happy with his portion
 Avi Ezri to Ibn Ezra loc. cit.