If Jesus was conceived by the Holy Spirit, why a Joseph family tree?

Why does the Bible record the family tree of Joseph leading to Jesus if Joseph wasn’t really the father of Jesus, in other words, the Holy Spirit—not Joseph—impregnated Mary?

In Matthew’s genealogy, notice the pattern:
Judah was the father of... (Mat 1:3)
Ram was the father of... (Mat 1:4)
Salmon was the father of... (Mat 1:5)
Josiah became the father of... (Mat 1:11)
But watch what happens when you get to verse 16:
Jacob was the father of Joseph the husband of Mary, by whom Jesus was born, who is called the Messiah (Mat 1:16).
Matthew does away with “the father of” pattern and says, “by whom Jesus was born.” Isn’t that interesting? But why? Verse 20 answers that question:
But when he [Joseph] had considered this, behold, an angel of the Lord appeared to him in a dream, saying, "Joseph, son of David, do not be afraid to take Mary as your wife; for the Child who has been conceived in her is of the Holy Spirit (Mat 1:20).
And verse 25...
...but kept her a virgin until she gave birth to a Son; and he called His name Jesus (Mat 1:25).
If Mary had never had sex before there is no way that baby just showed up by itself. Speaking back on homosexuality—now three states have approved same sex marriage, California, Connecticut, and Massachusetts—no matter how hard they try, two guys are never going to produce a baby. It just doesn’t work. There has to be the egg and the sperm. The Holy Spirit produced the sperm.

Why was that important? Because for Jesus to be sinless, His father had to be God, for Romans 5:12 tells us that sin passes not from Mom but from Dad. The reason my children are sinners is not because Kimberly my wife is a sinner (although she is), but because they get that from their Dad.

Now this leads to another question:

Why does the Bible record the bloodline of Joseph if Jesus didn’t come from Joseph?

Great question. Luke 3 also records a genealogy of Christ in the opposite order, ascending instead of descending. Instead of starting with Abraham and going all the way down to Jesus, he starts with Jesus and works all the way back to Adam, to God. King David had many sons. One of them was Solomon and another was Nathan (not the Nathan who rebuked David after he committed adultery). Nathan produced Mary, but Solomon produced Joseph.

The question then, is why was it recorded? Here is why: In 2 Samuel 7 God makes a covenant with David which means a promise. And he says, “David, your son is going to reign forever on the throne of Israel” (see 2 Sam 7:13-16). Solomon was a foreshadow of Israel. It was like when you throw a rock to make it skip over a lake. The promise bounced on Solomon but skips down to Jesus. Solomon was a foreshadow, a prefigure, of Jesus who was to come. For that prophecy in 2 Samuel 7 to be true, Jesus had to be the legal heir of that promise. He did not have to come from the bloodline, but legally, he had to be in the line. Legality was huge in Jewish culture. Jesus had to be through that line for that promise to be fulfilled, and that promise is fulfilled when Jesus returns and reigns on the earth for 1,000 years and then reigns forever into all eternity.