The point of the birth-record is to tie Jesus to the royal line of Israel (David) and to trace his ancestry back to Israel's principal ancestor (Abraham). It is important to Christians that the Messiah can be called the "Son of David" and the idea that he came at the "right" time is suggested by the threefold sequence of 14 generations. From Abraham to David, from David to the exile, and the exile to Jesus.
Tamar is the first woman given in the otherwise mostly patriarchal birth-record. Jesus' lineage is attached to Abraham through Perez.
According to Luke 3:23 the father of St. Joseph was named Eli.
The Greek term dikaios should be interpreted in reference to Joseph's observance of the law and not in reference to kindliness or niceness.
The particular law in question can either be tied to Deuteronomy 22:23-27 concerning a betrothed woman found not to be a virgin, or a vow of binding/denial detailed in Numbers 30.
From Jerome's commentary on Matthew: He who is joined to a prostitute "becomes one body with her." There is also a precept in the law that not only the accused but also the confidants of evil deeds are guilty of sin. If this is so, why is Joseph recorded to be just, when he is concealing the crime of his wife? This is a testimony to Mary that Joseph, knowing her chastity and perplexed by what had taken place, conceals in silence the mystery that he did not know about.
I believe the above point is reinforced by verses 24 and 25. Mary and Joseph's decision not to consummate their marraige upon the nisuim is very unorthodox and I believe it lends creedence to the idea that Mary had taken some kind of binding vow related to sexual chastity, and that the legalistic nature of Joseph's impulse to terminate the marraige is related to Numbers 30 rather than Deuteronomy 23.
Verse 25 neither confirms nor denies the perpetual virginity of Mary. "Until" contains no implication about what happened after Jesus' conception and birth. From Jerome's commentary on Matthew: "It does not, however, follow from the words 'before they came together' that they did come together afterwards; rather, the Scripture is simply pointing out what did not happen."