First, the Christian congregation is admonished by command and precedent from Scripture to stop socializing with those who are disorderly and not walking correctly. The reason for this is so that the congregation remain clean and maintain God's favor in order to be used by Him and to represent Him. Otherwise, God would expel or cut off the entire congregation. Please see: Rev. 2:5 and 1 Cor. 5:5, 6.
(For much more, see Disfellowshipping / Expelling.)
But just as Jehovah God requires that an unrepentant wrongdoer be expelled from the Christian congregation, He also lovingly shows that a sinner can be reinstated in the congregation if he repents and turns around. He can then be comforted by Christians who will confirm their love for him. (See 2 Corinthians 2:5-11; 7:8-13)
"No discipline seems for the present to be joyous, but grievous; yet afterward to those who have been trained by it it yields peaceable fruit, namely, righteousness." -Hebrews 12:11
For more, see
Discipline That Can Yield Peaceable Fruit