According to Jewish tradition, there are two ways to determine the legitimacy of a King. One is Divine appointment, or prophetic secessionism, and the other is that the King-to-be must have a direct line of relation to King David. As a result, King David's genealogy is the only genealogy in the Bible that is tracked so thoroughly. His family tree is known as the Messianic Line.*
Since direct lineage to King David is required to be King, one can understand why Matthew went through the trouble of sharing Jesus' genealogy at the beginning of his Gospel. The genealogy listed in the Gospel of Matthew seeks to honor the Messianic Line tradition of appraising a King's legitimacy.
However, Matthew's genealogy more specifically traces the lineage of Joseph, not Jesus. And, while Joseph does share a direct relation with King David, through Solomon, Joseph is not Jesus' biological father; he is his adopted father. Thus, Joseph's genealogy is just narrowly irrelevant to the kingship of Jesus Christ.
What Matthew's genealogy does offer to Jesus' legitimacy as Messiah, however, is its unique inclusion of women. It breaks from Jewish tradition to include women in a genealogy, but Matthew seems to have been very intentional about the particular women with whom he decided to break this tradition. Matthew includes Ruth, Rahab and Tamar, as well as Bathsheba in the genealogy for Jesus Christ. Each of these women were Gentiles, and very much not of a royal Jewish line.
Ruth, Rahab, Tamar and Bathsheba are not only lifted up as vital contributors to the Messianic narrative by being named in Luke's genealogy of Jesus, but they solidify Jesus' status as a King for the people. These women make Jesus who He is.