The Ninth Commandment is: Thou shalt not covet thy neighbors wife. It forbids taking willful pleasure in impure thoughts and desires. Impure thoughts and desires when deliberately taken pleasure in, are always mortal sins. Jesus Christ tells us that: "Whosoever shall look on a woman to lust after her has already committed adultery with her in his heart." (Matt. 5: 28.) Three things may cause temptations against purity: (a) The World: It makes little of modesty, bad books, bad pictures and movies, pornography on the Internet, and bad talk are the common sources of temptation in a corrupt world. (b) The Flesh: The passions rise in rebellion against the spirit. St. Paul says: "I see another law in my members fighting against the law of my mind.....Who shall deliver me from the body of this death? The grace of God through Our lord Jesus Christ." (Rom.7:23-25.)  (c) The Devil: "He goeth about like a roaring lion seeking who he may devour." and he can put evil images into our imagination.

Thus evil thoughts may come to us against our wishes. No matter how long they may stay or how violent they may be, they can do us no harm so long as we do not want them and do not consent to them. Do not willfully go into the way of temptation. Keep a guard on your eyes and ears by modesty. When temptations come pray: "Jesus, Mary and Joseph help me," and as far as it is in your power turn your mind to something else.

Source: Rev. W. Frean, Commentary on the Catechism.

There is a difference between divine and human law:

human law judges deeds and words but divine law also judges thoughts. This is because human laws are made by men who see things only exteriorly, but divine law is from God, who sees both external things and the very interior of men. "Man seeth those things that appear, but the Lord beholdeth the heart."

Reasons for this Commandment.  There are a number of reasons for this.
1. Man's desire has no limits, because desire itself is boundless. But he who is wise will aim at some particular end, for no one should have a aimless desire. "A covetous man shall not be satisfied with money." (Eccl. 5:10.) But the desires of man are never satisfied, because the heart of man is made for God. Thus says St. Augustine: "Thou hast made us for Thee, O Lord, and our heart is restless until it rests in Thee." Therefore, nothing less than God can satisfy the human heart.

2. Covetousness destroys peace of heart. The covetous man is ever solicitous to acquire what he lacks and to hold that which he has: "The fullness of the rich will not suffer him to sleep." (Eccl. 5:12.) "For where thy treasure is, there is thy heart also." (Matt. 6:21.)  it was for this reason, says St. Gregory, that Christ compared riches to thorns.

3. Covetousness makes riches useless to the wealthy and to others, because the covetous desire only to hold on to them. Covetousness destroys the equality of justice: "He that loveth gold shall not be justified. (Exod. 23:8.) Covetousness destroys the love of God and neighbor. For, as St. Augustine says. "The more one loves, the less one covets." Also, the more one covets the less one loves. "No man can serve two masters," so neither can he serve "God and mammon." (Matt. 6:24.)

Source: St. Thomas Aquinas, God's Greatest Gifts.

Inordinate Affections.

Whenever a man desires anything inordinately, he is immediately disquieted within himself. The proud and covetous are never at rest.  "The meek.....shall delight themselves in the abundance of peace." (Ps. 37:11.) The man that is not yet perfectly dead to himself is quickly tempted; and he is overcome in small and trifling things. The weak in spirit, and he who is in a manner carnal and prone to things of sense can hardly withdraw himself altogether from earthly desires. Therefore he has often sadness, when he withdraw himself from them; and easily falls into indignation if anyone resists him. And if he has attained that which he lusts after, he is forthwith burdened with remorse of conscience that he followed his own passion, which helps nothing in obtaining the peace he sought for. True peace of heart therefore is found by resisting our passions, not by obeying them. There is then no peace in the heart of carnal man, nor in him who is given up to outward things, but in the fervent and spiritual man.

Source:  Thomas a Kempis, The Imitation of Christ.