The rain comes up a few times in this poem, both as a literal description of what's going on and as a metaphor for other things. We think there are a few good reasons for that. Think of the way rain nourishes growing things, the way it cleans the world. It can be dangerous for sure, but here it's a pretty soft, quiet presence, which fits with the mood of the poem. Mist also shows up along with the rain – it's part of the same idea, but there are also really important differences, as we'll see.
Line 6: Here, the rain just helps to set the mood. It's a rainy, misty night, and it's hard for the speaker to see the lights of the town. This gives things a quiet feel, maybe even a little dreamlike. It also makes us feel like maybe this is the kind of night where you wouldn't want to be wandering around outside – the perfect kind of night to head in and curl up with a book, which is exactly what the speaker is going to do.
Line 12: Now the rain and the mist are used as a simile, a way for the speaker to describe the difference between "sadness" and "sorrow." Basically, he's saying that being a little sad is different from feeling real sorrow. They are related, like cousins, but they don't mean the same thing. See the comparison? You know that mist is water from the sky, but you wouldn't call it rain. In the same way, our speaker is bummed out, but he wouldn't call that feeling "sorrow."
Line 27: There's no mist here, but he does use rain for one more simile. In this case, he's comparing the way that rain falls from a cloud to the way that poems come rushing out of the heart of a poet. It's maybe a little tricky, since that gushing heart thing (line 26) is already a metaphor (poems don't come out of your heart, right?). Still, you get the point. He's trying to give us an image of how powerful and natural and spontaneous poetry can be.