Loki crept into Sif's chamber and stole her hair. Once Thor found out, he made Loki get her hair back or he would kill Loki with his own hands. Loki then pleaded that he would get her hair but but even more beautiful than before.
Loki went to Nidavellir to the dwarves and had them make Sif's new hair. The dwarves made Sif the most beautiful golden hair that ever existed. Not only did Loki get the hair for Sif, he was given a spear for Odin and a boat for Freyr.
Loki then went to leave but had a sneaky idea. Loki went back to another dwarves cave of Sindri and Brok. Loki taunted them that they couldnt build anything better than the gifts that was made for Sif, Odin, and Freyr.
Sindri and Brok took the challenge as Loki made a wager that if they won then they could cut off his head without damaging any other parts of his body.
Loki wanted the dwarves to lose the wager so he turned into a fly and bit Brok every time he was heating the fire and hoped that he would stop but never did. At the end Brok and Sindri made a golden bore for Freyr, Golden arm ring for Odin, and a Silver hammer for Thor. Brok went with Loki back to present the gifts and see who had the better gifts.
After finding out Brok and Sindri had made the better gifts, Loki tried to leave but Thor stopped him due to the wager made. Loki then retold the details to Brok the he could only cut off his head without injuring any otherr part of his body including his neck. After Brok realized that the task was impossible he let Loki go.