v.17-26. To illustrate God's patience in not punishing Cain until he had seen many generations of his offspring.
v.19. One of the (sinful) practices of Cain's line and into the generation of the Flood was to take two wives, commonly one for childbearing and one for pleasure. The latter was not meant to have children and was pampered like a bride, while the first was left bereft of companionship and to mourn as a widow throughout her life [x. Job 24:21] (Rashi; Midrash).
v.24-25. Why did Lamech kill Cain? The commentary stats (re. Genesis 4:23-24) that Lamech was blind and his son Tubal-Cain used to lead him. One day, mistaking Cain for an animal, his son bid Lamech shoot an arrow. When they discovered that they had killed Cain, in his grief Lamech flailed about and accidentally killed his son. Thus his wives refused to live with him. Lamech's plea was that sicne he had not killed intentionall, was he a murderer? But his wives refused to live with him because they feared punishment aganist their children by God. Lamech responded that if Cain's punishment (as an intentional murderer) was delayed until the seventh generation, then surely his punishment (as an unintentional murderer) would be delayed to the 77th generation. Rashi states that he used the number seventy-seven to mean many times seven, to denote 'a long period of time' and not necessarily 77 years.
v.26. The commentary states that the generation of Enosh introduced idolatry. The exact sin was to ascribe God-like qualities to inanimate objects. This created the abominable situation where to call in the Name of Hashem became profaned (Rashi).
Rambam (Hill. Avodas Kochavim 1:1-2) also explains how grievous misconceptions arose which led to idolatry. It began via star (sun, moon, planet) worship (Astrology) – when people began to feel they should honor the heavenly bodies as God's emmisaries to the world, just as it is proper to honor the ministers of a ruler. (I.E. similar would be the elevation of saints, Mary, or any other human, or object, such as “God's Son” or “Sun” for that matter.) Eventually this trend spread and became more and more corrupted until worshippers forgot to look past the heavenly bodies and see God, and then they forgot about God and assumed all powers were vested in whatever representation they chose to worship. (I.E. only worshiped the object (which they could see; which was in front of their eyes). This is “to place another God before His face”.)