The story of Tamar is brief, but important in the grand scheme of scripture. She first appears in the Bible after Judah moves to Canaan and takes a wife for himself. He then chooses Tamar, a Canaanite woman, as the wife for his oldest son Er.
“And Judah took a wife for Er his firstborn, whose name was Tamar.” – Genesis 38:6
After the death of Er, Onan is expected to have children with Tamar, according to tradition, but he pulls out and spills his seed, after having sex with her.
“And Judah said unto Onan, Go in unto thy brother’s wife, and marry her, and raise up seed to thy brother. 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. And the thing which he did displeased the LORD: wherefore he slew him also.” – Genesis 38:8-10
After the death of his second son, Judah tells Tamar to wait until his third son grows up, but he doesn’t keep his word (Genesis 38:11-14). Because he hadn’t kept his word, Tamar dressed up like a prostitute in order to trick Judah into getting her pregnant.
“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.” – Genesis 38:15-18
This story wouldn’t be important except for the fact that one of the sons (Pharez) that Tamar gives birth to, ends up being the line from which David, and Joseph (Mary’s husband) would come from.
“And it came to pass, as he drew back his hand, that, behold, his brother came out: and she said, How hast thou broken forth? this breach be upon thee: therefore his name was called Pharez. And afterward came out his brother, that had the scarlet thread upon his hand: and his name was called Zarah.” – Genesis 38:29-30
Tamar, being a Canaanite, means she was related to Ham by blood, and Ham was the father of the African nations. Because Tamar shared the same blood as Africans, it means that Pharez had African blood as well.