Neither shall you covet your neighbor's wife; and you shall not desire your neighbor's house, his field, or his manservant, or his maidservant, his ox, or his ass, or anything that is your neighbor's (Deut 5:21).
Everyone who looks at a woman lustfully has already committed adultery with her in his heart (Mt 5:28).
1. Internal sins
These two commandments refer to internal acts that are sins against the sixth and seventh commandments, which moral tradition classifies as internal sins. From a positive point of view, they prescribe living purity (the ninth) and detachment from material goods (the tenth) in our thoughts and desires, living in accord with Christ's words: Blessed are the poor in spirit, for theirs is the kingdom of heaven and Blessed are the pure in heart, for they shall see God (Mt 5:3 and 8).
The first point to clarify here is whether it makes sense to speak of “internal" sins. In other words, why should an act of the intellect and will that is not expressed in an external action be viewed as morally reprehensible?
The answer is not obvious since the lists of sins found in the New Testament appear to be mainly external acts: adultery, fornication, homicide, idolatry, sorcery, angry arguments, etc. And yet, in the same catalogue of sins we also find certain internal acts cited as sins: envy, evil desires, avarice. 
Jesus himself says that evil thoughts, murder, adultery, fornication, theft, false witness, slander ( Mt 15:19) come from man's heart. And referring specifically to chastity he teaches that everyone who looks at a woman lustfully has already committed adultery with her in his heart ( Mt 5:28). These texts are important for our understanding of morality since they stress that the source of human actions, and therefore of the good or evil in a person, is found in the desires of the heart, in what the person “wants" and chooses. The evil of murder, adultery, theft is not primarily in the physical reality of the action, or in its consequences (although these are an important part of it), but in the will, in the heart of the murderer, the adulterer, the thief, who in choosing that particular action is deciding on an orientation opposed to love for his neighbor, and therefore also to love for God.
The will always seeks a good, but at times what appears good is something that is not rationally ordered to one's overall good. The thief seeks something that he considers good, but the fact that the object belongs to another person makes the choice to obtain it something that cannot contribute to his own good as a person, that is, to the purpose of his life. In this sense, an exterior action is not required to decide if the will is heading in a good or bad direction. Anyone who decides to steal an object, even if something unforeseen keeps him from doing so, has “acted" badly. He has carried out an internal act of the will against the virtue of justice.
The goodness or wickedness of a person is rooted in the will, and so, strictly speaking, we should use these categories to refer to desires (what we want, approve), and not to thoughts. To speak of the intellect we use other categories such as true or false. When the ninth commandment forbids “impure thoughts" it is not referring to images or to the thoughts in themselves, but to the movement of the will which accepts the disordered pleasure provoked by a certain image (internal or external). 
Internal sins can be divided into:
– evil thoughts ( complacencia morosa ): these consist in imagining a sinful act without the intention to carry it out. It is a mortal sin if it involves a serious matter and if taking pleasure in it is sought or consented to;
– evil desire ( desiderium ): an internal desire for a sinful action that the person willingly accepts. This is not the same as the intention to carry it out (which always implies the actual desire to do so), although in many cases the person would carry it out if not for restraining reasons (such as the consequences of the action, difficulty in carrying it out, etc.);
– sinful complacence: that is, deliberately taking pleasure in an evil action carried out by oneself or by others. This renews the sin in the soul.
In themselves, internal sins are usually less serious that the corresponding external sins since the external action generally manifests a more deliberate willfulness. Nevertheless they are in fact very dangerous, above all for persons seeking to grow in friendship with God, since:
– they are committed more easily , since only the consent of the will is needed, and temptations can be more frequent;
– one pays less attention to them , since at times out of ignorance and at times out of a certain complicity with the passions, one does not want to recognize them as sins, at least venial ones, if there is imperfect consent.
Internal sins can deform the conscience, as when one accepts an internal venial sin as a matter of habit or with a certain frequency, although one seeks to avoid mortal sin. This deformation can give rise to manifestations of irritability, lack of charity, critical spirit, resigning oneself to having frequent temptations without struggling tenaciously against them, etc.  In some cases, this can lead to not wanting to recognize internal sins, hiding them with unreasonable excuses, and thus confusing one's conscience even more. As a result, self love easily increases, worries arise, humility and sincere contrition become more difficult and lukewarmness can easily result. In the struggle against internal sins, it is very important not to become scrupulous. 
Helpful in struggling against internal sins are:
– frequenting the sacraments, which give us grace or increase it, and heal us of our daily mistakes;
– prayer, mortification and work, seeking God sincerely;
– humility, which enables us to recognize our wretchedness without getting discouraged by our mistakes, and trust in God, knowing that he is always ready to forgive us;
– being sincere with God, with ourselves and in spiritual direction, taking special care of the examination of conscience.
2. Purifying the heart
The ninth and tenth commandments deal with the internal roots of sins against chastity and justice, and in a wider sense, of any sin.  In a positive sense, these commandments prompt us to act with a right intention, with a pure heart. Therefore they are very important, since they are concerned with the source giving rise to our external actions.
These internal operations are fundamental in the moral life of Christians, where the gifts of the Holy Spirit and the infused virtues are received in accord with a person's dispositions. Of special importance here are the moral virtues, which are dispositions of the will and of the sense appetites to do good. By giving importance to these factors, we can overcome a certain caricature of the moral life as merely a struggle to avoid sin, and discover the immensely positive panorama of the effort to grow in virtue and purify our heart.
These commandments refer more specifically to the internal sins against chastity and justice, which are clearly reflected in the text from Scripture that speaks of “three kinds of covetousness or concupiscence: lust of the flesh, lust of the eyes, and pride of life (cf. 1 Jn 2:16)" ( Catechism 2514). The ninth commandment focuses on controlling the concupiscence of the flesh, and the tenth on the concupiscence of other's possessions. That is, they prohibit us from being carried away consciously and voluntarily by these desires.
These disordered tendencies of concupiscence consist in “the rebellion of the 'flesh' against the 'spirit.' Concupiscence stems from the disobedience of the first sin" ( Catechism 2515). After original sin, no one has been free of concupiscence except our Lord Jesus Christ and the Blessed Virgin.
Although concupiscence in itself is not sinful, it inclines us to sin and gives rise to sin when it is not subject to reason enlightened by faith, with the help of grace. If one overlooks the reality of concupiscence, it is easy to think that all the tendencies we feel are “natural" and that there is nothing wrong in being guided by them. Many people realize that this is false when they consider the impulse to violence, seeing clearly that we must not be led by this impulse but must control it because it is not natural. And yet they do not want to recognize the same thing when it is a question of purity, claiming that there is nothing wrong in letting oneself be led by the “natural" stimuli. The ninth commandment helps us understand that this is not true, since concupiscence has wounded our nature, and what we feel as natural is frequently the consequence of sin, and needs to be controlled. The same could be said about the excessive desire for riches, or covetousness, prohibited by the tenth commandment.
It is important that we be aware of this disorder caused in us by original sin and by our personal sins, since this knowledge:
– incites us to pray : only God can undo original sin, the source of concupiscence; likewise only with his help will we succeed in overcoming this disordered tendency. God's grace heals the wounds of sin in our nature and raises us to the supernatural order;
– teaches us to love all creatures , since everything coming from God's hands was created good; it is our disordered desires that twist God's creation.
3. Struggling for purity
Purity of heart means having a healthy way of feeling. With God's help and our own struggle we can acquire an ever greater “purity of heart": purity in our thoughts and desires.
Christians obtain this purity through God's grace and through the virtue and the gift of chastity, through purity of intention and vision, and through prayer.  Purity of vision is not just refusing to look at something clearly unsuitable. It also requires purifying the use of our external senses, leading us to look at the world and at other men and women with supernatural vision, with Christ's eyes. This entails a positive struggle that enables us to discover the real beauty of all created reality and, in a special way, the beauty of those who have been formed in the image and likeness of God. 
“Purity requires modesty , an integral part of temperance. Modesty protects the intimate center of the person. It means refusing to unveil what should remain hidden. It is ordered to chastity to whose sensitivity it bears witness. It guides how one looks at others and behaves toward them in conformity with the dignity of persons and their solidarity" (Catechism 2521).
4. Poor in heart
“Desire for true happiness frees man from his immoderate attachment to the goods of this world so that he can find his fulfillment in the vision and beatitude of God" ( Catechism 2548). “The promise [of seeing God] surpasses all beatitude . . . In Scripture, to see is to possess . . . Whoever sees God has obtained all the goods of which he can conceive." 
Material goods are good as a means but not as an end. They cannot satisfy man's heart, which is made for God and is not satisfied with material well-being.
“The tenth commandment forbids greed and the desire to amass earthly goods without limit. It forbids avarice arising from a passion for riches and their attendant power. It also forbids the desire to commit injustice by harming our neighbor in his temporal goods" ( Catechism 2536).
Sin is turning away from God and turning towards creatures. Attachment to material goods nourishes the root of this turning towards creatures and leads to blindness of spirit and hardness of heart: if anyone has the world's goods and sees his brother in need, yet closes his heart against him, how does God's love abide in him? ( 1 Jn 3:17). We cannot serve both God and riches (cf. Mt 6:24; Lk 16:13)
The exaggerated importance given to material well-being today, putting it above many other values, is not a sign of human progress. It implies a lessening and degradation of man, whose dignity resides in being a spiritual creature called to eternal life as a son of God (cf. Lk 12:19-20).
“The tenth commandment requires that envy be banished from the human heart" ( Catechism 2538). Envy is a capital sin. “It refers to the sadness at the sight of another's goods" ( Catechism 2539). Envy can give rise to many other sins: hatred, calumny, detraction, disobedience, etc.
Envy is opposed to charity, which leads us to desire what is good for others as a manifestation of the love we have for them. The virtue of humility also helps us in this struggle since envy often arises from pride (cf. Catechism 2540).
Catechism of the Catholic Church , 2514-2557.
St Josemaria, “For They Shall See God" in Friends of God , 175-189; “Detachment" in Friends of God , 110-126.
 Cf. Gal 5:19-21; Rom 1:29-31; Col 3:5. After making an appeal to shun fornication, St Paul writes: that each one of you know how to control his own body in holiness and honor, not in the passion of lust like heathen who do not know God . . . For God has not called us for uncleanness, but in holiness " (1 Thess 4:4-7). In doing so, he emphasizes the importance of the feelings, which lie at the root of our actions, and the need to purify them for the sake of attaining sanctity.
 Thus one needs to keep clear the difference between “feeling" and “consenting" in reference to a particular passion or movement of the senses. Only when there is consent of the will is it a question of sin (if the matter is sinful).
 “You play around with temptations, you put yourself in danger, you fool around with your sight and with your imagination, you chat about... stupidities. And then you are anxious that doubts, scruples, confusion, sadness and discouragement might assail you.—You must admit that you are not very consistent" (St Josemaria, Furrow , 132).
 “Whatever happens, there is no need to worry as long as you don't consent. For only the will can open the door of the heart and let that corruption in" (St Josemaria, The Way , 140; cf. ibid. , 258).
 “The tenth commandment concerns the intentions of the heart; with the ninth, it summarizes all the precepts of the Law" (Catechism 2534).
 “With God's grace he will prevail:
— by the virtue and gift of chastity , for chastity lets us love with upright and undivided heart;
— by purity of intention , which consists in seeking the true end of man: with simplicity of vision, the baptized person seeks to find and to fulfill God's will in everything (cf. Rom 12, 2; Col 1, 10);
— by purity of vision , external and internal; by discipline of feelings and imagination; by refusing all complicity in impure thoughts that incline us to turn aside from the path of God's commandments: 'Appearance arouses yearning in fools' (Wis 15,5);
— by prayer " (Catechism 2520)
 “The eyes! Through them many iniquities enter the soul. — What experiences like David's! If you guard your sight you have assured the guard of your heart" (St Josemaria, The Way , 183). “Dear Lord, I find beauty and charm in everything I see! I will guard my sight at every moment, for the sake of Love" (St Josemaria, The Forge , 415).
 St. Gregory of Nyssa, Orationes de beatitudinibus , 6: PG 44, 1265A. Cf. Catechism 2548.