The Old Testament sets its hope on the emergence of a messiah in the line of King David (See 2Sam 7:1-17; Mk 12:35-37). The New Testament picks this up and sees it fulfilled in Jesus. (E.g. Mk 10:47) Nothing surprising in that is there? David was, after all, designated by God who sees the heart (1Sam 16:7), and made Israel a great nation politically. Except that David was also an adulterer and a murderer. (2Sam 11:1-27) It is easy to forget this when we read in the New Testament of Jesus spoken of in terms of King David. And Matthew's Gospel emphasizes the fact that Jesus is the product of the liaison between David and Bathsheba. (Matthew mentions Bathsheba specifically, whereas virtually all the other entries in the genealogy of Jesus are solely the males. See Matt 1:6b) What are we to make of this? The importance of repentance? (That is, God can make something of a repentant sinner?) Yes, but there is something more profound going on here. God can use sin and sinners for God's own purposes. Think of the cross, a terrible sin, yet the point of salvation. And Jesus seems to prefer sinful humanity in calling disciples. We like to think of the great saints as above reproach, but they didn't think of themselves in such a way, and when we cut through the hagiography we find grace moulding itself around, and sometimes using, continuing failure. And Jesus, as God in the flesh, is incarnated in a real human nature, and is at one with sinners in his crucifixion and death.
Why would God do it this way? Pride and perfection leave less room for God, and perfection can lead us to give the credit to human beings rather than God. Not so the sinner. God uses the weak to shame the strong and their wisdom. God has more space to work a surprising result through the weakness of the human vessel. (1Cor 1:18-31)