Dedicated to the Lord Jesus Christ Who loved us, gave Himself for us, and washed us from our sins in His own Blood; and to the Church, which is His body.

Even the genealogies are inspired by God and profitable (2 Timothy 3:16). Matthew traces Jesus' genealogy through Joseph back to Solomon. There was a curse placed on one of Solomon's sons named Jechonias (Jeremiah 22:24-30), which Jesus avoided by being born of a virgin.
Luke mentions Jesus as being the supposed son of Joseph who was the son of Heli. It was actually Mary who was the daughter of Heli. This was done in other Old Testament instances (Numbers 27:1-11; 36:12 with Ruth 4:6). Mary's genealogy was also from David but through Nathan, a half brother of Solomon. The lineage was preserved but the curse was bypassed.
These genealogies show the infinite wisdom of God in fulfilling His promises despite the corruption of man. In fact, these genealogies are full of murderers, adulterers, and every sort of pervert know to man, and yet these same people were used of God, not because of their actions but in spite of them. This means there is still hope for us.
God has never had anyone qualified working for Him yet and we won't be the first. The history of God's dealings with man reveal that He has always used less than perfect vessels. We can rejoice and take comfort in the fact that God uses us because of our faith and not our holiness.