There are two reasons David gives for his desire to have ready access to dwell in the sanctuary (Tabernacle, later the Temple):
לחזות בנעם יי
Lachazot b’no’am Adonai
To gaze on the beauty of Adonai
And to contemplate/inquire in his palace
What does he mean by these?
John Goldingay (Psalms, Vol. 1: Baker Commentary) suggests we look to Psalm 90:17 for a parallel. There the “beauty of Adonai” means the beauty of his deeds for those he loves.
Others think David is being quite mystical here, gazing on the Presence of Adonai in the sanctuary. This does not have to mean that he enters behind the veil and gazes on the Presence above the Ark (which is forbidden, see Leviticus 16). Simply by being so near to God’s Presence, he gazes with his mind on the Nearness of the Holy One.
One interpretation sees David’s delight in the sanctuary as a source of prayer and guidance as king. The other sees his delight in contemplation.
Goldingay thinks the contemplation of God’s Presence unlikely since he feels the Bible avoids language of seeing God. I think he is wrong about that. The Bible uses language of seeing, but not seeing, seeing the Presence (Shechinah, Sefirot) but not the Direct Being of God (Ein Sof).
There is no reason to think David’s meaning isn’t both. He gazes on the Nearness of God with his mind and is comforted as king, that God is accessible to him in prayer, reveals things to him with mysterious guidance as to a prophet, and does beautiful things for David and Israel.
Though we are not David, though we have no access to the sanctuary, God’s Nearness is present to us in other ways. Even if we might not receive the level of revelation David did, to gaze and contemplate is also the closest we can come to the Infinite One whom we desire above all things.