-->
According to Zamakhshari and Razi, the construction of this clause (beginning with "so that") is meant to bring out the idea that one's belated realization, in the hereafter, of having been "close unto Satan" is the most terrible consequence of deliberate sinning.
To entertain a feeling of friendliness, instead of aversion, to Evil, is in itself a degradation of our nature, a Penalty which Allah imposes on our deliberate rejection of the Truth. And the friendliness to Evil also implies the sharing of the outlawry of Evil.