Not trying to victimize Loki. Atleast not completely. Im just trying to point out that we shouldnt jump straight into calling someone a villain when it isnt 100% clear if they're the good guy or bad guy of the film.
I think theres a world of difference between tweens swooning over Draco and someone pointing out that a Mythological and Comic being are far from the villain archetype and that their Cinematic counterpart reflects the original traits of the character fairly well and very consistently through out all 3 films hes featured in.
And again you are citing Loki in The Avengers which is the height of his villainy and as I pointed out earlier its very questionable how much control he was in at that point in the MCU timeline.
About half an hour into the movie theres a conversation between Loki and a Chituari (General?)
The only line that points out that it was a two way street is when the general tells Loki "You will have your war". Its pretty clear there where Loki stands there, its obvious that hes not reluctant to do there bidding.
How ever right after that the general also says (After Loki taunts him for there inability to secure the Tesseract)
"If you fail, if the Tesseract is kept from us, there will be no realm, no barren moon, no crevasse where I can't find you. You think you know pain? He will make you long for that so sweet as pain".
All the while Loki has a pretty scared face
The threat of Thanos cosmic power aside he still has to deal with being ordered around by the Chituari them selves.
Later in the movie we saw just how easily the Hulk over powered Loki and made a joke of him, But we also saw just how easily a coordinated attack a small squadron of Chituari were able to subdue the Hulk.
Loki knows just how large the Chituari forces are. Im sure he knows he cant go toe to toe with their whole army if he defies them.
I guess my point is , That if Thanos AND the Chituari request you do something for them. You do it , and be happy that they might let you live and even keep a planet for yourself after its all said and done. Because remember The Avengers wasnt about Loki taking over the earth. It was about Thanos securing the Tesseract on Earth and moving on to the other realms taking over the universe.
Yes Loki had something to gain if Thanos plan succeeded in The Avengers, and yes its definitely morally wrong for him to side with this absolute faceless evil in the film. But there is most definitely evidence in the film that things are much larger then just Loki lust for the Throne and its clear that he is not calling the shots and his life hangs in the balance. And as far as the Trickster archetype goes.. that falls perfectly into it. Siding yourself with questionable characters for self preservation and mutual gain is trickster 101.