Spirit Fragments are an important plot device in Hyrule Warriors and Hyrule Warriors Legends. They are 4 pieces of Spirit of Evil's soul that was separated and placed under seal after the Demon King was defeated by an incarnation of The Hero, thus ending the cycle of endless conflicts and battles over the Triforce. Three of the Fragments where placed under seal in different eras, while the fourth and final piece was placed under seal by the Master Sword in the Temple of the Sacred Sword.
However part of the Demon King's spirit sealed by the Master Sword was able to partially escape from its seal and eventually managed possess and corrupt the Guardian of Time, transforming her into Cia after driving the light from her heart and granting her the Triforce of Power. Cia was then manipulated by the evil spirit into opening the Gate of Souls, summoning monsters from across the ages to serve her, leading to the creation of the Cia's Dark Forces, which brought war to the land of Hyrule. During a battle between her forces and the Hyrulean Forces in the Valley of Seers, Cia manages to steal the Triforce of Wisdom and Triforce of Courage, obtaining the complete Triforce. The spirit then manipulated Cia into using the Triforce to warp time and space creating gateways to the 3 different eras where the 3 fragments where held. Breaking the seals on each of the three fragments, Cia drew them into her body granting her greater dark power.
After the Hyrulean Forces managed to close the gate in each era and Cia's defeated by Midna and Lana in the Palace of Twilight, the fragments left Cia's body and combined together restoring the physical body of none other than the Demon King, Ganondorf. Ganondorf reveals he had manipulated Cia into freeing the 3 fragments of his soul and revealed that he planned free the fourth and final fragment himself once he had taken the Triforce from Cia. However Cia sent the Triforce of Courage and Triforce of Wisdom back to Link and Zelda, catching Ganondorf off guard, allowing her to briefly seal him with a Magic Circle.
The final fragment remained under seal by the Master Sword, until Link removed it from its pedestal at the behest of Princess Zelda in order to defeat Cia and her Dark Forces. However the magic barrier around the Temple of the Sacred Sword managed to keep it temporarily under seal.
However following Cia's defeat and death, Link did not return the Master Sword to its pedestal and the barrier containing it eventually broke without the power of the Master Sword to keep it contained, allowing Ganondorf to fully restore himself.
After Ganon is defeated, it is implied that Link, Zelda, and Lana use the Triforce to reseal the Soul Fragments, however Lana reveals that in order to restore the seal completely Link & Zelda had to return the Master Sword to its pedestal. As Link places the sword in the pedestal, the Soul Fragment tries to prevent Link from returning the sword as part of one final attempt by Ganondorf to escape again. However Zelda assists Link and together they return the sword to its pedestal, restoring the seal on the Demon King's soul.
The Soul Fragments resemble the Poe Soul from Twilight Princess which were pieces of Jovani's soul which he sold to the Poes for unimaginable wealth, but Jovani ended up being turned into a gold statue and later sought Wolf Link's aid to regain his soul by having him defeat the Imp Poes and retrieving the Poe Souls. Both Poe Souls and Soul Fragments have a similar design and are depicted as the souls of humans (a Hylian and a Gerudo respectively).
Interestingly, both men had their souls split as a direct result of their greed, Jovani sold his for wealth and Ganondorf had his soul split by an incarnation of Link to put an end to Ganondorf's continuous attempts to obtain the Triforce and conquer Hyrule. However in both cases, they managed to get someone (Wolf Link in Jovani's case and Cia in Ganondorf's case) to collect the fragments of their souls and were able to partially restore themselves after regaining a certain number (as Jovani regained his mobility, yet retained his body of gold after Wolf Link obtained 20 Poe Souls and Ganondorf managed to restore his physical form after Cia freed 3 pieces of his soul) of fragments and were restored completely when they regained all of them (as Jovani was returned to normal when all 60 Poe Souls were obtained and Ganondorf was revived when the fourth and final fragment of his soul was freed).