By "David" here the Lord is meant;{1} and by "His kingdom" heaven, as is evident from the following passage:
I will raise unto David a righteous Branch, and He shall reign as King, and shall deal intelligently and shall execute judgment and righteousness in the land (Jer. 23:5).
Jehovah is exalted, for He dwelleth on high; He hath filled Zion with judgment and righteousness (Isaiah 33:5). "Zion" also means heaven and the church.{2}
I, Jehovah, doing judgment and righteousness on the earth,
for in these things I delight (Jer. 9:24).
I will betroth thee unto Me forever, and I will betroth
thee unto Me in righteousness and judgment (Hosea 2:19).
O Jehovah, in the heavens Thy righteousness is like the
mountains of God, and Thy judgments are like the great
deep (Psalm 36:5, 6).
They ask of Me the judgments of righteousness, they long
for an approach unto God (Isaiah 58:2). So in other
places.
{Footnote 1} By "David" in the prophetic parts of the Word, the
Lord is meant (n. 1888, 9954).
{Footnote 2} In the Word "Zion" means the church, and
specifically the celestial church (n. 2362, 9055).
217. In the Lord's spiritual kingdom there are various forms of government, differing in different societies, the variety being in accord with the functions performed by the societies; and the functions of these are in accord with the functions of all things in man to which they correspond. That these are various is well known, the heart having one function, the lungs another, the liver another, the pancreas and spleen another, and each sensory organ another. As in the body these organs perform various services, so there are various services pertaining to the societies in the Greatest Man, which is heaven for the societies there correspond to these organs. That there is a correspondence of all things of heaven with all things of man may be seen in its own chapter above (n. 87-102). But all these forms of government agree in this, that they look to the public good as their end, and in that good to the good of the individual.{1} And this is so because everyone in the whole heaven is under the auspices of the Lord, who loves all, and from Divine love ordains that there shall be a common good, from which each individual shall receive his own good. Each one, moreover, receives good according as he loves the common good; for so far as he loves the common good he loves all and everyone; and as that love is love of the Lord he is to that extent loved by the Lord, and good comes to him.