A Commentary, Critical, Practical, and Explanatory on the Old and New Testaments, by Robert Jamieson, A.R. Fausset and David Brown  at sacred-texts.com
ecc 5:1(Ecc. 5:1-20)
From vanity connected with kings, he passes to vanities (Ecc 5:7) which may be fallen into in serving the King of kings, even by those who, convinced of the vanity of the creature, wish to worship the Creator.
Keep thy foot--In going to worship, go with considerate, circumspect, reverent feeling. The allusion is to the taking off the shoes, or sandals, in entering a temple (Exo 3:5; Jos 5:15, which passages perhaps gave rise to the custom). WEISS needlessly reads, "Keep thy feast days" (Exo 23:14, Exo 23:17; the three great feasts).
hear--rather, "To be ready (to draw nigh with the desire) to hear (obey) is a better sacrifice than the offering of fools" [HOLDEN]. (Vulgate; Syriac). (Psa 51:16-17; Pro 21:3; Jer 6:20; Jer 7:21-23; Jer 14:12; Amo 5:21-24). The warning is against mere ceremonial self-righteousness, as in Ecc 7:12. Obedience is the spirit of the law's requirements (Deu 10:12). Solomon sorrowfully looks back on his own neglect of this (compare Kg1 8:63 with Ecc 11:4, Ecc 11:6). Positive precepts of God must be kept, but will not stand instead of obedience to His moral precepts. The last provided no sacrifice for wilful sin (Num 15:30-31; Heb 10:26-29).
ecc 5:2rash--opposed to the considerate reverence ("keep thy foot," Ecc 5:1). This verse illustrates Ecc 5:1, as to prayer in the house of God ("before God," Isa 1:12); so Ecc 5:4-6 as to vows. The remedy to such vanities is stated (Ecc 5:6). "Fear thou God."
God is in heaven--Therefore He ought to be approached with carefully weighed words, by thee, a frail creature of earth.
ecc 5:3As much "business," engrossing the mind, gives birth to incoherent "dreams," so many words, uttered inconsiderately in prayer, give birth to and betray "a fool's speech" (Ecc 10:14), [HOLDEN and WEISS]. But Ecc 5:7 implies that the "dream" is not a comparison, but the vain thoughts of the fool (sinner, Psa 73:20), arising from multiplicity of (worldly) "business." His "dream" is that God hears him for his much speaking (Mat 6:7), independently of the frame of mind [English Version and MAURER].
fool's voice--answers to "dream" in the parallel; it comes by the many "words" flowing from the fool's "dream."
ecc 5:4When thou vowest a vow unto God--Hasty words in prayer (Ecc 5:2-3) suggest the subject of hasty vows. A vow should not be hastily made (Jdg 11:35; Sa1 14:24). When made, it must be kept (Psa 76:11), even as God keeps His word to us (Exo 12:41, Exo 12:51; Jos 21:45).
ecc 5:5(Deu 23:21, Deu 23:23).
ecc 5:6thy flesh--Vow not with "thy mouth" a vow (for example, fasting), which the lusts of the flesh ("body," Ecc 2:3, Margin) may tempt thee to break (Pro 20:25).
angel--the "messenger" of God (Job 33:23); minister (Rev 1:20); that is, the priest (Mal 2:7) "before" whom a breach of a vow was to be confessed (Lev 5:4-5). We, Christians, in our vows (for example, at baptism, the Lord's Supper, &c.) vow in the presence of Jesus Christ, "the angel of the covenant" (Mal 3:1), and of ministering angels as witnesses (Co1 11:10; Ti1 5:21). Extenuate not any breach of them as a slight error.
ecc 5:7(See on Ecc 5:3). God's service, which ought to be our chief good, becomes by "dreams" (foolish fancies as of God's requirements of us in worship), and random "words," positive "vanity." The remedy is, whatever fools may do, "Fear thou God" (Ecc 12:13).
ecc 5:8As in Ecc 3:16, so here the difficulty suggests itself. If God is so exact in even punishing hasty words (Ecc 5:1-6), why does He allow gross injustice? In the remote "provinces," the "poor" often had to put themselves for protection from the inroads of Philistines, &c., under chieftains, who oppressed them even in Solomon's reign (Kg1 12:4).
the matter--literally, "the pleasure," or purpose (Isa 53:10). Marvel not at this dispensation of God's will, as if He had abandoned the world. Nay, there is coming a capital judgment at last, and an earnest of it in partial punishments of sinners meanwhile.
higher than the highest-- (Dan 7:18).
regardeth-- (Ch2 16:9).
there be higher--plural, that is, the three persons of the Godhead, or else, "regardeth not only the 'highest' kings, than whom He 'is higher,' but even the petty tyrants of the provinces, namely, the high ones who are above them" (the poor) [WEISS].
ecc 5:9"The profit (produce) of the earth is (ordained) for (the common good of) all: even the king himself is served by (the fruits of) the field" (Ch2 26:10). Therefore the common Lord of all, high and low, will punish at last those who rob the "poor" of their share in it (Pro 22:22-23; Amo 8:4-7).
ecc 5:10Not only will God punish at last, but meanwhile the oppressive gainers of "silver" find no solid "satisfaction" in it.
shall not be satisfied--so the oppressor "eateth his own flesh" (see on Ecc 4:1 and Ecc 4:5).
with increase--is not satisfied with the gain that he makes.
ecc 5:11they . . . that eat them--the rich man's dependents (Psa 23:5).
ecc 5:12Another argument against anxiety to gain riches. "Sleep . . . sweet" answers to "quietness" (Ecc 4:6); "not suffer . . . sleep," to "vexation of spirit." Fears for his wealth, and an overloaded stomach without "laboring" (compare Ecc 4:5), will not suffer the rich oppressor to sleep.
ecc 5:13Proofs of God's judgments even in this world (Pro 11:31). The rich oppressor's wealth provokes enemies, robbers, &c. Then, after having kept it for an expected son, he loses it beforehand by misfortune ("by evil travail"), and the son is born to be heir of poverty. Ecc 2:19, Ecc 2:23 gives another aspect of the same subject.
ecc 5:16Even supposing that he loses not his wealth before death, then at least he must go stripped of it all (Psa 49:17).
laboured for the wind-- (Hos 12:1; Co1 9:26).
ecc 5:17eateth--appropriately put for "liveth" in general, as connected with Ecc 5:11-12, Ecc 5:18.
darkness--opposed to "light (joy) of countenance" (Ecc 8:1; Pro 16:15).
wrath--fretfulness, literally, "His sorrow is much, and his infirmity (of body) and wrath."
ecc 5:18Returns to the sentiment (Ecc 3:12-13, Ecc 3:22); translate: "Behold the good which I have seen, and which is becoming" (in a man).
which God giveth--namely, both the good of his labor and his life.
his portion--legitimately. It is God's gift that makes it so when regarded as such. Such a one will use, not abuse, earthly things (Co1 7:31). Opposed to the anxious life of the covetous (Ecc 5:10, Ecc 5:17).
ecc 5:19As Ecc 5:18 refers to the "laboring" man (Ecc 5:12), so Ecc 5:19 to the "rich" man, who gets wealth not by "oppression" (Ecc 5:8), but by "God's gift." He is distinguished also from the "rich" man (Ecc 6:2) in having received by God's gift not only "wealth," but also "power to eat thereof," which that one has not.
to take his portion--limits him to the lawful use of wealth, not keeping back from God His portion while enjoying his own.
ecc 5:20He will not remember much, looking back with disappointment, as the ungodly do (Ecc 2:11), on the days of his life.
answereth . . . in the joy--God answers his prayers in giving him "power" to enjoy his blessings. GESENIUS and Vulgate translate, "For God (so) occupies him with joy," &c., that he thinks not much of the shortness and sorrows of life. HOLDEN, "Though God gives not much (as to real enjoyment), yet he remembers (with thankfulness) the days; for (he knows) God exercises him by the joy," &c. (tries him by prosperity), so Margin, but English Version is simplest.