Loki hasn't been outright evil for a while now and is more often than not a force for good as of late.
In this case, he was pretending to side with some Celestials who were driven insane by a mutant strain of the same disease that killed the Progenitor but was actually playing a long con that not only cured them, but got the Avengers to reform after having previously broken up.