Deuteronomy 7:1 “When Yahweh thy God shall bring thee into the land whither thou goest to possess it, and hath cast out many nations before thee, the Hittites, and the Girgashites, and the Amorites, and the Canaanites, and the Perizzites, and the Hivites, and the Jebusites, seven nations greater and mightier than thou”.
These along with Ammon and Moab were all people with unrestricted sexual practices that would taint their lineage or were children of incest. These were forbidden people for the children of Israel to marry.
Judah took as wife a Canaanite woman named Shuah. From this came three sons, Er, Onan and Shelah. You will never find them listed in the lineage of Israel. God worked around Judah’s sin.
Genesis 38:6 “And Judah took a wife for Er his firstborn, whose name was Tamar.”
God killed Er. Judah then sent Onan to create a first born for Er.
Geneis 38:9 “And Onan knew that the seed should not be his; and it came to pass, when he went in unto his brother’s wife, that he spilled it on the ground, lest that he should give seed to his brother.”
Onan had made a public promise to raise up seed for his dead brother, but due to selfishness, broke that promise. God then killed Onan.
When Tamar realized that Judah was not going to give her to Shelah, she tricked Judah and bore two sons to Judah.
Genesis 38:14-18 “And she put her widow’s garments off from her, and covered her with a vail, and wrapped herself, and sat in an open place, which is by the way to Timnath; for she saw that Shelah was grown, and she was not given unto him to wife. When Judah saw her, he thought her to be an harlot; because she had covered her face. And he turned unto her by the way, and said, Go to, I pray thee, let me come in unto thee; (for he knew not that she was his daughter in law.) And she said, What wilt thou give me, that thou mayest come in unto me? And he said, I will send thee a kid from the flock. And she said, Wilt thou give me a pledge, till thou send it? And he said, What pledge shall I give thee? And she said, Thy signet, and thy bracelets, and thy staff that is in thine hand. And he gave it her, and came in unto her, and she conceived by him.”
When word came that Tamar was with child she was brought before Judah.
Geneis 38:25-26 “When she was brought forth, she sent to her father in law, saying, By the man, whose these are, am I with child: and she said, Discern, I pray thee, whose are these, the signet, and bracelets, and staff. And Judah acknowledged them, and said, She hath been more righteous than I; because that I gave her not to Shelah my son. And he knew her again no more.”
Thus the lineage of Judah was kept pure by God’s hand. Judah’s sin was that he married a Canaanite woman. Then he had intercourse with a woman without intent to become her husband. Then when he found out that Tamar had become pregnant he wanted her killed in punishment.
When he found out that he was the man who Tamar had intercourse with, he had no choice but to acknowledge her righteousness. She was righteous through the entire story. Scripture allows for a man to take a woman to wife or give her to his son. His son refused and died so she was righteously Judah’s woman.
Without another separate article Gideon sinned in much the same way.
Judges 8:31 “And his concubine that was in Shechem, she also bare him a son, whose name he called Abimelech.”
Gideon’s concubine was a Canaanite woman. It was her son who killed all but one of Gideon’s sons. Judges 9:5. Gideon’s sons were killed because they were not Canaanites.