User blog comment:Oms1315/Thoughts on Loki's staff in Avengers Film/@comment-24751588-20130112013823/@comment-1895174-20130112225349

If I remember correctly, Whedon brought it to one of the Comic Con conventions in 2010. It had me speculating that Thanos was going to show up in The Avengers long before we actually knew anything about it. And since Whedon's on record saying his earliest scripts for the movie (the ones that had Wasp in Black Widow's place) featured a second "I-am-contractually-bound-not-to-tell-you-who-it-is" villain, it's very possible Thanos initially played a bigger role in the film than the cameo we got of him at the end.

Also, consider this as a potential scenario as to how he gets hold of it:
 * > The Other told Loki in The Avengers that there was no place he could hide from his master's [Thanos'] wrath if he failed to conquer Earth and secure the Tesseract
 * > Loki fails to do that; Thor takes him and the Tesseract back to Asgard
 * > Holy crap everything Thanos wants is in Asgard
 * > Dark Elves do some stuff in the upcoming Thor: The Dark World that threatens...something
 * > Thor & companions leave Asgard to take care of Dark Elves
 * > Thanos uses opportunity to attack Asgard (because that's definitely not what happened in the first Thor movie); gets revenge on Loki and secures Tesseract
 * > Takes Infinity Gauntlet out of Odin's vault with him

Something like that.