From the OT word study dictionary:
חָמַד ḥāmad, חֲמוּדָה ḥamûdāh, חֲמֻדָה ḥamudāh: A verb meaning to take pleasure in, to desire, to lust, to covet, to be desirable, to desire passionately. The verb can mean to desire intensely even in its simple stem: the tenth commandment prohibits desiring to the point of coveting, such as a neighbor’s house, wife, or other assets (Ex. 20:17; cf. Ex. 34:24). Israel was not to covet silver or gold (Deut. 7:25; Josh. 7:21) or the fields and lands of others (Mic. 2:2). The word can also express slight variations in its basic meaning: the mountains of Bashan, including Mt. Hermon, looked in envy on the chosen mountains of Zion (Ps. 68:16[17]); the simple fool delighted in his naïve, senseless way of life (Prov. 1:22); and a man was not to lust after the beauty of an adulterous woman (Prov. 6:25).
The word expresses the idea of finding pleasure in something as when Israel took pleasure in committing spiritual fornication among its sacred oaks (Isa. 1:29). The passive participle of the simple stem indicates someone beloved or endearing (Isa. 53:2) but has a negative meaning in Job 20:20, indicating excessive desiring or craving (cf. Ps. 39:11[12]).
The passive stem indicates something that is worthy of being desired, desirable; the fruit of the tree of the knowledge of good and evil appeared inviting to make a person wise (Gen. 2:9; 3:6; Prov. 21:20) but proved to be destructive. The plural of this verbal stem expresses satisfaction or reward for keeping God’s Law (Ps. 19:10[11]).
Looking at the word in Matthew, from TDNT(Little Kittel) has this to say:
The group is more common in the epistles than the Gospels. It may denote hunger (Lk. 15:16), longing (Lk. 22:15), or a desire for the divine mysteries (Mt. 13:17) or for anything good (Phil. 1:23; 1 Tim. 3:1). But it usually denotes evil desire as indicated by the object (a woman in Mt. 5:28, other things in Mk. 4:19), by the orientation (cf. Gal. 5:17), by the instrument (the heart in Rom. 1:24, the body in Rom. 6:12, the flesh in Eph. 2:3, the eyes in 1 Jn. 2:16), or by the manner (carnal in 1 Pet. 2:11, worldly in Tit. 2:12, defiling in 2 Pet. 2:10, etc.). A Jewish model for Paul’s use of the term for the tenth commandment is found in Rom. 7:7. Hence one need not postulate Stoic influence except perhaps in 1 Th. 4:5. In any case, disobedience, not irrationality, is the evil in epithymía.