In 2 Samuel 7.12-13, God promised King David that a blood descendent of King David's would one day rule from David's throne. God further promised David that this descendent would rule over His kingdom forever.
Of course we now know that it was Jesus Christ who God sent to rule forever from David's throne. (Luke 1.32)
To rule as King from David's throne, Jesus Christ HAD to meet TWO REQUIREMENTS as follows:
a) Jesus had to be a blood descendent of David, AND
b) Jesus had to be LEGALLY entitled to sit on David's throne.
God had a problem in having Jesus meet the second requirement named above. Here are the reasons:
a) David had many children, but only one of those children became king after David died. The son who became king was Solomon.
b) To be LEGALLY entitled to sit on David's throne, a person had to be a descendent of David through the kingly line of David's descendants. The kingly line of David's descendents began with King Solomon.
c) One of the kings who came along many years after David died was King Jeconiah (also called Coniah, and Jehoiahchin). King Jeconiah was, of course, a descendent of King Solomon and thus was in the kingly line of David. King Jeconiah did a great sin against God. Accordingly, God ordained that NO blood descendent of King Jeconiah would ever again sit on David's throne. (Jeremiah 22.30)
d) Because of what God said in Jeremiah 22.30, Jesus could NOT be a blood descendent of King Jeconiah. This meant that Jesus could not be a blood descendent in the KINGLY line of King David.
e) In summary, God's problem was this. To keep God's promise to David (2 Samuel 7.12-13) Jesus had to meet the following REQUIREMENTS:
1) Jesus had to be a blood descendent of King David, AND
2) Jesus had to be LEGALLY entitled to the throne, BUT
3) Jesus must not be a blood descendent through David's kingly line, because Jesus must NOT be a blood descendent of King Jeconiah (Jeremiah 22.30).
God's solution to the problem was as follows:
a) Among all of King David's children were two sons: Solomon and Nathan (2 Samuel 5.13-14).
b) Solomon was in the kingly line. Nathan was not.
c) Accordingly, anyone descended from Nathan would be a blood descendent of King David but would NOT be legally entitled to David's throne.
d) As explained in Matthew chapter 1, Joseph was legally the father of Jesus but he was NOT physically the father of Jesus, because Jesus was born of a virgin named Mary. Mary, of course, became Joseph's wife.
e) Matthew 1.1-17 gives the LEGAL geneology of Jesus Christ through His legal father, Joseph. Note that this geneology is fully within the kingly line of David (Mt 1.1), including King Solomon (Mt 1.6) and King Jeconiah (Mt 1.11).
f) Therefore, since Jesus was legally Joseph's son, and since Joseph was in the kingly line, Jesus was legally entitled to sit on the throne of David. However, Jesus was NOT a blood descendent of King Jeconiah.
g) Jesus was, of course, a blood descendent of His mother Mary.
h) The geneology in Luke 3.23-38 is the geneology of Mary, the mother of Jesus.
i) Luke 3.31 shows that Mary was a blood descendent of King David through David's son Nathan.
a) Since Jesus was legally Joseph's son in the kingly line, Jesus was and is legally entitled to the throne of David.
b) Since Jesus was a blood descendent of David's son Nathan, through Jesus's mother Mary, He is a blood descendent of King David, as God promised He would be.
c) Since Jesus was Joseph's legal son but not his blood descendent, Jesus was not a blood descendent of King Jeconiah.
d) Accordingly, God kept all of His promises to King David except one -- that King Jesus would rule over an eternal kingdom. That promise WILL be fulfilled in the future (Dan 9.7, Rev 19.6).