A long time ago, after the war between the Aesir and Vanir that had destroyed the walls of Asgard, a certain giant came to the kingdom of the gods and stated that he could build a fortification around Asgard in three seasons. The price was the goddess Freya and the sun and the moon.
Freya immediately was upset about this and the other gods of course thought the price was much too high and they would never give up their sister goddess to a giant.
Before they refused the giant's offer though, Loki chimed in and came up with a plan. He said they should make the deal but only if the giant could build the wall in one winter. The gods thought this would be impossible to do so they approached the giant with this challenge.
To the surprise of the gods the giant accepted this arrangement. He made the gods take oaths that he would not be harmed during the the building of the wall and he would receive his due payment on completion.
After oaths were made the giant immediately began construction on the fortification. He brought his great horse Svadilfari to help.
The gods were astonished at the speed which the giant was working and even more so astonished at the speed the horse was working, dragging giant boulders. The horse seemed to be working twice as hard as the giant.
It seemed like the fortification would be done in less than a winter and the gods confronted Loki. They blamed him for a faulty plan and if he didn't stop the giant from building the wall in time it would be his life. Loki agreed to do his best to distract the giant and therefore caused him to lose time in building the protective wall around Asgard.
Loki realized the giant couldn't do the job in time without his horse's help so he shape-shifted into a mare and whinnied at Svadilfari. The great stalion immediately turned and gave chase to what he thought was a female horse in heat.
The giant could not catch his steed and Svadilfari pursued Loki for nights on end thus causing the giant to not be able to finish the wall in time.
Svadilfari did finally catch Loki though and Loki became pregnant and soon birthed the eight legged horse Sleipnir which became Odin's steed. A great, grey horse that could traverse the nine worlds with ease. Even down to the hall of Hel herself. Sleipnir is spoken of in the Volsunga saga as the ancestor of Grani, Sigurd's horse that Odin led him to find.
The giant however was paid by the gods for his efforts in almost completing in the fortification of Asgard: Thor's hammer to his head making it explode into tiny fragments the size of bread crumbs.