The Spiritual Stones are quest items in The Legend of Zelda: Ocarina of Time. They are keys to unlock the Door of Time within the Temple of Time to access the Sacred Realm and the Master Sword.
The Spiritual Stones, the Kokiri's Emerald, Goron's Ruby, and Zora's Sapphire, are guarded by the Kokiri, Gorons, and Zoras, respectively. Each of these races will only open their hearts and minds to those who know the melody of the Royal Family of Hyrule.
Ganondorf, the evil leader of the Gerudos, attempts to take the Spiritual Stones, but the Kokiri, Gorons, and Zoras, knowing he is up to no good, refuse to give him the stones. In retaliation, he curses each of them. To acquire their stones, Link must help them out by undoing the evil that Ganondorf has spread. Once Link has all three stones, he must go to the Temple of Time and place the stones in the altar by playing the "Song of Time" to open the Door of Time.
The Kokiri's Emerald, the Spiritual Stone of the Forest. is in the possession of the Great Deku Tree. To earn it, Link must go inside the Great Deku Tree and break the curse Ganondorf put on him by defeating Queen Gohma. Though he succeeds in doing so, he is too late, as the Deku Tree was doomed from the beginning, and he dies shortly after giving Link the stone.
The Goron's Ruby, the Spiritual Stone of Fire, is a hidden treasure of the Goron race, passed down by their leaders. Ganondorf seals the Dodongo's Cavern, the Goron's food source, with a boulder, telling them he will only reopen it if they give him the stone. In addition, the cavern becomes infested with Dodongos. Darunia, the Gorons' leader, cheered up after Link plays "Saria's Song" for him, agrees to give Link the stone, on the condition that he prove himself worthy by purging the Dodongo's Cavern of the creatures plaguing it. Upon defeating King Dodongo inside the cave, a grateful Darunia gives Link the Goron's Ruby, as promised.
The Spiritual Stone of Water, AKA Zora's Sapphire, was given to Princess Ruto by her mother, who said she should give it to whoever will be her husband. She loses it inside Jabu Jabu while feeding him after she gets swallowed as well, and enlists Link to help her search for it. After finding it however, she is attacked by a Big Octo and disappears. After Link defeats Barinade, a monstrous jellyfish-like entity feeding on Jabu Jabu's life force, and reunites with Ruto, she develops feelings for him and rewards him with Zora's Sapphire as a symbol of their supposed engagement.