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.