Each of these women recognized the expectation of the "Promised Seed" by faith in God's covenant with Abraham and David, respectively.
For an amplified discussion of Tamar, Rahab, and Ruth, and their respective goal of the pursuit-and-capture of the "Promised Seed" by faith, please click here. (Please note however that Bathsheba is not mentioned by name in the Matthew genealogy, but only mentioned to show that the kingly right of Jesus to the Davidic throne was through Solomon.) And so finally it is Mary who is named and understands from the angel Gabriel that she was to be the actual mother of The Promised Seed (compare Luke 1:32 with the "help to Israel" mentioned by Mary in Luke 1:54-55), and so she provided her consent to the angel Gabriel to conceive (Luke 1:38).
In other words, the listing of these four women by name was to highlight how the "Promised Seed" was expected by them through their understanding and faith in the Abrahamic and Davidic covenants. That is, they desired and therefore each had sought to conceive the Promised Seed by faith.
Last but not least, we must note that these four women plus Bathsheba were women of "shame": if she was not unattractive, then she was indeed a widowed wallflower (Tamar); another was the mother of Boaz, who was a Canaanite prostitute (Rahab); another widow was a cursed Moabite (Deut 23:3) that had married Boaz (Ruth); one was an adulteress (Bathsheba); and finally the last was a woman of abject penury and of no account (Mary). In other words, Jesus was not a man with a distinguished racial pedigree to his name.