Aggadah # 115 takes Psalm 24, familiar to many of us from the liturgy, and transforms its parallel questions and answers into a conversation between King Solomon and the gates of the Temple. The gates challenge Solomon when he tries to bring the Ark of the Covenant in, and Solomon asserts that they should open for the "King of Glory," which apparently is not convincing for the gates; they respond only when Solomon claims the right to bring in the Ark based on his father's good deeds.
The textual problem is only apparent when we compare this version of the story to the Biblical story of the dedication of Solomon's Temple in both I Kings and II Chronicles. While these versions differ slightly (as is usual between Kings and Chronicles), they agree that "The priests brought the Ark of the Lord's Covenant to its place in the inner sanctuary of the Temple, in the Holy of Holies..." (II Chronicles 5:7 and a similar verse in I Kings 8:6). Neither version mentions anything about Solomon himself bringing the Ark into the Temple or about any difficulty encountered bringing it inside. In both Biblical versions of the story, the priests are able to put the Ark into its proper place inside the Temple without incident, and the cloud of the Divine Presence comes to rest in the Temple shortly afterwards. The quote from Chronicles that, in our aggadah, supposedly guarantees Solomon entrance does not actually appear until after Solomon has officially dedicated the Temple and completed his blessings and exhortations, long after the Ark is safely inside.
So why invent a scenario that directly conflicts the Biblical account? Why create a scene in which Solomon himself has so much trouble bringing the Ark inside the Temple? What textual problem is this aggadah answering?
I think this aggadah stems from anxieties or conflicts surrounding the Ark and the establishment of the Temple. The Biblical text itself evidences some discomfort about the Ark. Both Kings and Chronicles tell us, "Ein baaron rak shnei luchot haavanim asher hiniach sham Moshe..." "There was nothing in the Ark except for the two tablets of stone that Moses placed there..." (I Kings 8:9 and the parallel verse in II Chronicles 5:10) The strange negative phrasing implies that someone, at some point, alleged that there was something else in the Ark. This is the same piece of furniture that zaps people when they try to keep it from falling (II Samuel 6:6-8), strikes down whole Philistine cities with plagues (I Samuel ch. 5&6), and precedes the Cloud of the Presence pretty much everywhere. So there's clearly a danger of idolatry with this object and a fear that the barely-contained power of the Ark will suddenly be unleashed, despite the fact that if the Temple is going to be the legitimate "heir" to the Mishkan, the dwelling-place of God's presence, the Ark must come to rest there. Hence the gates' ambivalence about letting it in (and that of the rabbis of the Babylonian Talmud who authored this midrash).
This aggadah also tries to justify the idea that despite being the fruit of King David's sinful alliance with Batsheva, Solomon is worthy of being the one to build and consecrate the Temple. There is even a hint in the first question, "Who is the King of Glory?" that the gates think Solomon is referring to himself-- and perhaps he is, until the gates' question makes him reconsider. Solomon not only has to unequivocally demonstrate his humility before God, but also has to show that he recognizes that his merit derives from his father before he can establish the Temple. In one fell swoop, this aggadah justifies the claim of the entire Davidic line while simultaneously expressing deep-seated questions about whether or not the Temple itself presents the danger of idolatry. Go rabbis, and sorry, Indiana.