Which one is correct and why?
It was done yesterday.
It had been done yesterday.
It just depends on the context, or what you want to convey about the context. If you say to me "It had been done yesterday", I'll try to think of something that happened earlier today before which you're saying it was done. Because this is what the construction demands -- a previous temporal anchor. Say, for example, this morning someone criticized me for not getting my car repaired, but at that time, I had already taken care of it the previous day. Then the temporal anchor is the criticism.
If I don't know of any such earlier event, I'll probably just assume there was something significant that happened earlier, and I'll be expecting you to fill me in.