All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
A believer who wants to preserve his religion should only befriend a pious believer who would remind him of Allaah if he is heedless, and he would enjoin him to do good and forbid him from doing evil. He should avoid socializing with disobedient people in general unless there is a need or a benefit, like him calling them to Allaah. The advice of the Prophet is: ''Do not befriend except a believer and it is only a pious person who should eat your food.” This is a Hasan [good] Hadeeth reported by Ahmad, Abu Daawood, At-Tirmithi, Ibn Hibbaan and Al-Haakim .
The scholars stated that mixing too much with people without being controlled by Islamic conditions is among the causes of the disease of the heart. In general, this leads to major disadvantages, among which is idle talk, getting involved in matters that do not concern a person, and probably a person would hear backbiting, scorning and mocking, and it might be that he is unable to change anything, and so, he will be questioned about this on the Day of Judgment.
Based on the above, if a person can control his mixing with the people by Islamic conditions, then this is better for him, but if he is unable to do so, then it is better to avoid them. The scholars stated that the excellence of mixing with people or being isolated from them depends on the circumstances and differs according to the person and the environment. For more benefit, please refer to Fataawa 133933 and 86478.
Finally, it should be noted that the sins of the tongue are very serious, especially backbiting and slandering; for more benefit, please refer to Fatwa 81748.
Allaah Knows best.