The Gospel writers boldly associate Jesus’ birth with David’s name. And they do this in order for us to learn about Jesus’ birth as a fulfilment of ancient promises.
In 2 Samuel 7v12–13, God had promised David that a future son—the seed or offspring of David—would rule forever on the throne.
There are at least seven places in the Gospels of Matthew and Luke where the name of David is mentioned in relation to Jesus’ birth.