I have entries on this scheduled for the Exegetical Commentary, but the short answer is that this is addressed to the disciples to encourage them to stay the course despite the hardships coming.
I would also argue that it’s meant to be taken in context of the mysterious “new commandment” to “love one another”, which wouldn’t seem to be a new commandment at all but common sense so common that (as Jesus says on the Sermon on the Mount) even pagans and traitors and prostitutes do that (as a way of shaming His audience into doing better than that).
But that new commandment comes after Judas’ departure to go betray Jesus – which Jesus is carefully preparing them for learning in other portions of the Final Discourse, too.
Anyway, regardless of whether Jesus is actually telling the disciples that they can only stay Christian if they’re willing to love Judas, too, despite his coming betrayal (which by the way would fit 1 John’s exhortation that whoever says he loves God but hates his brother is a liar and God is not in him), He’s certainly giving them encouragements not to incur God’s wrath by abandoning their position. That doesn’t have anything to do with God loving or not loving people to start with, it’s a relative question of whether God will keep supporting them.
(Unless of course we posit that GosJohn offers completely contradictory testimony about God’s love for sinners; but that would be a position against accepting GosJohn for religious purposes at all, even if we still accepted it as having significant historical accuracy.)