Both are good grammar. Choosing between the two is about what you want to say.
The first one says it rained yesterday. That's all you wanted to say. It rained. You said it. Now it's done.
The second is when you want to take someone back to that moment and talk more about what was happening while it had been raining. You want to add to it. For example:
It had been raining hard all day yesterday. At about 5 o'clock I suddenly realised that I had hung my laundry outside to dry and forgotten it. I needed a clean shirt for work tomorrow, but now it would be dripping wet.
For me, the difference in the types of past tense like this is: where do you want your reader to be? If they are here now, then "it rained." If they are transported back to yesterday in your story, then "it had been raining" when the story unfolded.
If something "had been happening," it will always feel like there was more to the story.