As we know all four women were non-Jews. and Jesus had the Gentile blood! Tamar was a Canaanite, Rachel was a native of Jericho; Ruth the most beautiful character - was a Moabite and Bathsheba, although the daughter of an Israelite, was considered a Hittite, becuse of her marriage to Uriah.
Why were they mentioned in the geneology of Jesus because perhaps Mathew's way of telling us that in Jesus, the barrier between the Jews and Gentiles are torn down. In Jesus there is neither Jew nor Gentile. God is not a racist.
He is also trying to tell us that in Jesus the barrier between male and female are torn down. Men and women stand equally before God. God is not a sexist.
By including these notoriously sinful women, Mathew is preaching the grace in Geneology. The point is that God can overcome any and all sin and can use the most soild of human soul to accomplish his greatest purpose in history. This does not make sin o.k. It simply magnifies the Grace of God. For Jesus came not to call or invite to repentence the righteous but sinners (those who are erring and are not free from sin). Here he tells us that he also came 'through sinners'. Martin Luther King said: "Christ is not the kind of person who is ashamed of sinners - infact he puts them in his family tree!".
The message is that it is Jesus who saves his people from their sins, whether it be deception, adultery incest or even murder.