This psalm was probably written for the celebration that would occur when the Ark of the Covenant would be returned to the people of Israel. As I read it I find the flow of the psalm to be building on itself. First, the statement that the Lord dwells over the whole earth (v.1-2). There is not one place in which God does not claim ownership. The earthly dwellings and the seas are the Lords.
Second, because he is King over all the earth. Because He is so Great, who can ascend his hill? I read this, who can come into his presence? The response is on with clean hands and a pure heart. With such a person rests the blessing and righteousness of God (v.3-6).
Third, is this interesting and somewhat confusing image of gates and doors. It seems that the expression is this welcoming presence of the God whose hill we cannot ascend and whose reign is over all the earth. Because this God is so great the gates to the city and the doors that let people in and out of the city need to stretch to their greatest of heights so that God can come to dwell with us.
I find it interesting, the question is asked who can ascend his hill, but the Psalm seems to conclude, God comes to us. Toil and struggle we may to get to God, but ultimately it is the King of Glory who comes to dwell with us.