Man’s best friend
ויאמר לו יקוק לכן כל-הרג קין שבעתים יקם וישם יקוק לקין אות לבלתי הכות-אתו כל-מצאו
Hashem said to him: “Therefore, anyone who kills Cain will be avenged sevenfold.” Hashem placed a sign for Cain, so that no one who finds him will harm him
Hashem severely punished Cain for murdering his brother. In response, Cain stated that his sin was too great to bear He admitted the error of his ways. In response, Hashem promised justice against anyone who harms Cain. To assuage his fears from foreign attackers, the Torah says that Hashem gave Cain a “sign”. We aren’t told what this is. One opinion of our Sages is that Hashem gave Cain a dog. This seemingly was meant to bea guard dog, which would fight off any foe. The problem is, it’s hard to fit this into the verse. How could placing a sign mean a dog? It should have said that Hashem gave Cain protection, or something similar.
If we look closely, we’ll see that Cain sinned in two ways: First of all, he sinned against Hashem. When he brought an offering to G-d, he chose from the worst of his produce. Secondly, by killing his brother, he obviously sinned against his fellow man. His sin against Hashem was coming from a lack of gratitude. He should have brought from the best he had, like his brother did, and his first fruits. Why did Cain kill his brother? Some say it was because he wanted to be the sole inheritor of his father. He couldn’t stand the thought of sharing half the world with his brother. This obviously came from a bad character, an inability to be satisfied with one’s lot. Worse than that, it came from an insatiable hunger, where had to resort to taking that which was not his.
This latter trait is known to be common amongst dogs. They’re constantly hungry and are always looking for the next treat to snatch. On the other hand, they are known to be the most loyal of creatures. They’re grateful to their masters and will do whatever is within their power to protect them. They are loyal despite their master’s inability to fully satiate them.
It makes sense then that Hashem would give Cain such a creature as a sign. When Cain realized and admitted the error of his ways, Hashem wanted to make sure he never forgot his mistakes. He very easily could slide back into his bad character. The dog will remind Cain to always be grateful to his Master for all that He gives him. Furthermore, he will see the dog’s insatiable hunger, and remember that it is a repugnant quality for him to possess.
 Based on Kesav Sofer to Genesis 4:15
 Genesis loc. cit.
 V. 13. The Kesav Sofer is following one opinion in Bereishis Rabbah 22:11 who reads it as a statement, as a form of vidui (Etz Yosef and Maharzu ad. loc.). The Ramban ad. loc. also reads it this way. Cf. Rashi ad. loc., who reads the verse rhetorically
 Bereishis Rabbah 22:12, brought by Ramban ad. loc. The other opinions suggest Hashem had the sun follow him around (see Tosafos to Avodah Zarah 25a s.v. למשה), or gave him tzara’as, or a horn. One opinion said that Cain himself became a sign for all murderers of what will happen to them, or a sign for those who sincerely repenty
 Rashi to v. 3, quoting Bereishis Rabbah 22:5
 V. 4
 Bereishis Rabbah 22:7. See there for other opinions
 See Isaiah 56:11