The entire poem can be thought of as a dialogue. It begins with an anonymous speaker. That speaker addresses the knight and asks him a question (stanzas 1-3). The knight answers, and speaks for the rest of the poem (4-12). The poem ends with knight restating his answer to the speaker's question. Though this dialogue is limited (the knight doesn’t give the speaker a chance to ask follow-up questions), it complicates the poem by giving it two perspectives.
Dialogue is one of the main tools that fiction writers use to deepen and enrich their characters. It works similarly in this poem. In the case of the knight, it gives him the space to explain himself. As for the speaker who questions the knight, by engaging in a dialogue this speaker comes across as curious, empathetic, observant, and perhaps slightly worried. With the repeated question (“O what can ail thee”), the speaker expresses his or her desire to understand what afflicts the knight. With comments on the knight’s appearance (he is alone, pale, and anguished), the speaker empathizes with the knight, perhaps conveying a similar state of despair.
The dialogue also serves a technical purpose by providing context and depicting the appearance of the knight. In other words, the first speaker’s presence adds a concrete quality to this world. Without the speaker, there would be no way to contextualize the knight in the world around him. It wouldn’t be very believable if the knight, whose mind revolves around the memory of the Lady, described the autumnal present with the same specificity as the speaker, nor would it be elegant if he introduced himself, saying, “Hello, I am a knight-at-arms. I am lovesick and slowly dying.” Instead, the speaker describes the bleakness of the "real" world, while the knight focuses on his own fantastical memories.