It's arguably in character, but what's the audience meant to think? Are we meant to root for them to be together? Loki has been very villianous, but in the MCU he's often potrayed as a charming rogue that the audience naturally roots for.
Of course you're meant to root for them to be together. Loki had always been of an ambiguous morality but it's pretty implicit that he was never truly evil. Selfish and power hungry, sure, but never evil. Things went to shit when he found out he was a jötunn but before then he clearly got on very well with his family.
The only time he did explicitly evil things, the Mind Gem in his scepter was apparently amplifying his negative emotions in much the same way it had the Avengers, and there was that moment of lucidity at Stark Tower where he's visibly scared of what he's done so I can believe it. He's not normally like that, y'know? Using armies to conquer has never been his style and even Thor was surprised to hear Loki had killed eighty people in two days. He probably hadn't killed that many people in the last thousand years. Even when he made the deal with his dad to let the Frost Giants into Asgard, it was all a ruse so he could kill the guy.
Loki only turned out the way he did because, in his own words from his 2012 self, he had come to believe love was a lie. He believed that not only did his adoptive family not love him, but that he was little more than a hostage and that he would never be able to escape Thor's shadow. Yet Thor 2 and Thor 3 both proved that Loki was softening on that stance in the years after the first Avengers movie as he was realising just how much his adoptive family meant to him and how much he meant to them and how, by the events of Infinity War, he finally accepted that he is the rightful king of Jötunnheim anyway so Odin was actually right all along. The dream of peace between Asgardians and jötunn was in the bag with Thor and Loki being their respective Kings. At least that was the case before Thanos fucked everything up.
So yeah, I'd say you're meant to root for Loki. His journey has been a fascinating one and we saw him die to protect the universe. Dude deserves a happy ending. In fact, since there's no chance of Tom Hiddleston returning, I'd love for Sylvie to hop on over to the MCU proper, fully aware of what her other self did, and become an enigmatic but supportive member of New Asgard. Imagine Thor's face when he finally finds out that not only does the multiverse exist and Loki is still alive in some universes, but that one of them has been helping him from the shadows for a while and he never knew.