Is there a difference between the following sentences?
It was my birthday yesterday.
My birthday was yesterday.
When should I use "it was something yesterday/a few days ago/..." and when should I use "something was yesterday/..."?
I agree the two are very nearly identical, and could often be used interchangably. I would say the subtle difference mostly concerns the object that is being emphasized, either "the birthday" or the implied "it".
"It" likely refers to a particular day — yesterday, last Tuesday, etc. Someone might ask, "What was special about yesterday", to which you might reply "It (the day) was my birthday".
In contrast "My birthday was yesterday" puts the focus on the event itself. Someone might ask "When was your birthday", to which you might answer "My birthday (it) was yesterday".
Clearly, they both mean the same thing, but they would be used on different occasions. If someone said to you ‘What are you doing for your birthday tomorrow?’ you might reply, with a steely look, ‘My birthday was yesterday.’ On the other hand, if someone said to you ‘Hey, how come you’ve got all those presents?’ then an appropriate reply would be ‘It was my birthday yesterday.’ But much depends on how each is said.