According to Norse mythology, Loki was not only a god but was also considered a Trickster (a deity that breaks the rules of gods or nature, sometimes maliciously but usually with ultimately positive effects). However, he wasn't born a god. His parents were two giants, Farbauti and Laufey. So, he had to sneak his way into the title. Loki was associated with fire and magic and some believe he shows a great resemblance with Syrdon, a demonic creature from Caucasian legends. Loki was the first Anti-Hero, quick-witting his way out of the tight corners and confrontations caused by his misdeeds, but as time went on, he became increasingly unpleasant.
The gods were finding it hard to build Asgard due to limited funds. Not very surprising since money and banks hadn't been invented yet. Everything had been completed except for a large protective wall to surround it. Loki came up with the brilliant plan to hire a giant for the job. The giant asked for the sun, moon and the goddess Freya as payment. Thinking he wouldn't be able to get the job done, the gods reluctantly agreed. What they didn't know was the giant had help, a stallion named Svadilfari who could haul large boulders.
With three days to go, Freya along with the other Norse gods were getting a little nervous and so was Loki. So, how was a trickster suppose to rectify the situation. Considering he was also a shapeshifter, the answer was pretty simple. He changed into a mare and seduced the stallion into following him into the woods, away from the stone pile. Without Svadilfari, the giant didn't meet the deadline which made him angry. He attempted to kidnap Freya, but Thor stopped him by cracking the giant's skull with his hammer.
Meanwhile, Loki was having the time of his life frolicking in the fields. In fact, he may have had a little too much fun because he became pregnant and gave birth to a fine baby boy stallion with eight legs. The horse, Sleipnir, was given to Odin as a gift which put him in good with the god.
Loki had many adventures with Odin's son. Among them, Thor dressed up in drag to appear as the prospective bride for a giant. Despite being the perfect fall guy, he was always good for getting out of tight situations whenever Loki needed him. Among his other mischievous deeds, Loki cheated the dwarfs until they stitched his mouth shut and even though he had three wives (Glut, Angrboda and Sigyn), he never missed the opportunity to take advantage of a Goddess.
He may not have earned the title God, but Loki was considered the most scandalous one of all time. His pranks came to an end when he caused the death of Balder, the god of light. His punishment was to be chained to three larger boulders: one under his shoulders, one under his loins and one under his knees. A poisonous snake that dripped venom was also placed above his head. His wife Sigyn caught the venom in a bowl. When she must empty it, the venom falls on Loki's face which makes him twist in pain, causing earthquakes. On the day of Ragnarok, Loki's chains will break and he will lead the giants into battle against the gods.
Sources: God Checker and Encyclopedia Mythica