The Adventure of Link
In The Adventure of Link, the flute is the Dungeon item of the Palace on the Sea. It serves two important functions: clearing the River Devil from the road leading into southeastern Hyrule south of Nabooru, and revealing Three-Eye Rock Palace at Three Eye Rock.
A Link to the Past
The boy in the Haunted Grove tells Link to keep the Flute. Surely, it must have some sort of mysterious power. It does. If Link plays the Flute in front of the Weathercock in Kakariko Village, the Duck appears and will be at Link's disposal."
"Use the Flute to call the Duck. Choose one of the eight locations."
How to Find it
In the Dark World, Link can speak to the creature sitting on the tree stump in the Haunted Grove. He will tell him that he used to play his flute for all the animals there. Then he will give Link the Shovel and tell him to dig up his Flute from near some flowers. Link can find the Flute back in the Light World if he digs around the top-left area of the Grove. If he heads back to the Dark World and talks to the creature, he will say he can no longer play the Flute in his form, so he allows Link to have it. Then he will transform into a tree.
Link can head back to Kakariko Village in the Light World and go into one of the first houses on the left and play the flute in front of the old man. If he does, the man will wake up and ask if you met his son, implying that he is the Flute Boy's father. Then, Link can go outside to the statue of a bird in the middle of the village. If he plays the Flute while standing on the S and facing the bird, the bird will come to life and fly off. Now, every time Link plays the Flute in the Light World, the bird will appear and fly him to one of eight locations.