The phrase has a somewhat contentious origin: some attribute it to Ecclesiastes 10:20 "Do not revile the king even in your thoughts, or curse the rich in your bedroom, because a bird in the sky may carry your words, and a bird on the wing may report what you say." Another explanation is a simple allusion to carrier pigeons or other such messenger birds.
Yet others believe this refers to Act 2 of Richard Wagner's Siegfried, in which the main character comes to understand that the song of a small bird instructs him to steal a ring and helmet.
An older source is the Norse legend of Sigurd who slew the dragon Fafnir and got a bit of dragon's blood on his tongue when he was roasting its heart. This immediately made it possible for Sigurd to understand what the birds were saying, and what they were saying was a warning that Regin would not keep his word, but instead planned to kill Sigurd. Richard Wagner borrowed this tale for his own version, of course.