( وَكَذَٰلِكَ) (And thus): Referring to the debate that took place between the jinn and the human beings
(نُوَلِّي بَعْضَ الظَّالِمِينَ بَعْضًا) (will We make some of the wrongdoers allies of others): As what happened with those who followed the devils and their path, who listened to their whispers of evil and sin, Allah (swt) also causes the wrongdoers to be their allies; an allegiance which brings only darkness and injustice.
(بِمَا كَانُوا يَكْسِبُونَ) (for what they used to earn): Allah (swt) did not do them injustice, their punishment is the result of their deeds and for leaving the Path of Guidance of Allah (swt).