There are multiple reasons for why Loki attacked Earth.
The first and most obvious motive is also the simplest - Revenge.
From Avengers Assemble;
Thor: We were raised together, we played together, we fought together. Do you remember none of that?
Loki: I remember a shadow, living in the shade of your greatness. I remember you tossing me into an abyss, I who was and should be king!
Thor: So you take the world I love as recompense for your imagined slights? No, the Earth is under MY protection, Loki!
Loki has always felt that he was over-looked by Odin in favour of Thor, the true born son of Odin and the first in line for the throne. He's jealous and angry, and he thinks that he would make a much better king than Thor would - so after Thor ruins his plan to rule Asgard (the events of Thor), he chooses to take revenge against his brother by attacking the world that Thor loves.
The second reason is that he was asked to.
A long-running but (as of yet) unresolved plot throughout the Marvel Cinematic Universe so far is that Thanos wants to unite the six Infinity Stones. One of these, the Space Gem, is stored inside the Tesseract, which the Red Skull used to power Hydra weapons in Captain America: The First Avenger and at the start of Avengers Assemble is being experimented on in SHIELD.
Thanos gifted Loki the sceptre that he wields throughout The Avengers in order to retrieve and return the Tesseract to him. In return, he gives Loki a Chitauri army with which to attack the planet. This is beneficial for both Thanos and Loki - Loki gains the ability to travel to Earth and an army with which to take it, and Thanos gets the Space Gem.
The third reason is a little more complicated and (as of yet) mostly guesswork - but Loki needed to return to Asgard.
After falling off the Bifrost Bridge, Loki had no real way to return to Asgard, the place that he wishes to rule. However, by attacking Earth (and losing the war), Thor takes him back to Asgard to be imprisoned in the dungeons. Loki later uses this imprisonment to his advantage, and as of the end of Thor: The Dark World actually manages to take control of Asgard without anyone knowing - becoming the King that he originally wanted to be way back in Thor.
How much of this was planned out in advance is still currently unknown, but knowing that Loki is the God of Mischief means that this could well be a very valid reason for why he attacked Earth - the first part in a much larger plan.