Jesus says to not judge others, however he also says, "Don't give that which is holy to the dogs, neither cast your pearls before the pigs, lest perhaps they trample them under their feet, and turn and tear you to pieces." (Matthew 7:6 WEB)
So what's the deal? What is Jesus really talking about?
When Jesus talks about judging others, he says, "Don't judge, so that you won't be judged. For with whatever judgment you judge, you will be judged: and with whatever measure you measure, it will be measured to you. Why do you see the speck that is in your brother's eye, but don't consider the beam that is in your own eye?" (Matthew 7:1-3 WEB)
Jesus then immediately says, "You hypocrite! First remove the beam out of your own eye, and then you can see clearly to remove the speck out of your brother's eye." (Matthew 7:5 WEB)
So we see here that Jesus is actually not saying to not judge, but instead he is saying to not be hypocritical. He is criticizing those who point out other people's sins, yet sin themselves.
Jesus then immediately says in the next verse, "Don't give that which is holy to the dogs, neither cast your pearls before the pigs, lest perhaps they trample them under their feet, and turn and tear you to pieces." (Matthew 7:6 WEB)
In order to decide who are "dogs" or "pigs" a judgment has to be made. This statement is clearly a metaphor, but nevertheless Jesus is instructing us to make a decision about who is not worthy of what is holy.
Jesus also calls this: "By their fruits you will know them." (Matthew 7:16 WEB) He makes this statement is the same chapter, just a few verses later.
Here, in Matthew 7:16, Jesus is talking about false prophets, but again a judgment has to be made. Not only is Jesus NOT saying to not judge, he actually is telling us to judge others based on their actions.
Why? Because our actions reveal the truth about us. Someone can say, "I'm not a killer," but if they kill someone, their actions have proven them wrong. Someone can say, "I'm not a thief," but if they steal, then their actions have proven them wrong. Someone can say, "I have repented," but if they recommit that sin, then they have not repented.
So the idea that we are to "not judge" others is an incorrect teaching.
However, there are two types of judging.
There is objective judgment of "Calling it what it is" and there is subjective judgment of looking down on people and viewing them as less than you because of what they do. Objective judgments are non-sinful, and we see Paul doing it in the Bible as well. However, subjective, arrogant, prideful, belittling judgments are obviously sinful, as the bible repeatedly speaks against arrogance, pride, and belittling others.
This is also different than the subject of forgiveness, which the Bible is very clear that we are to forgive completely always. However, as we will see in Paul's recommendations, forgiveness is not the same as trusting someone or socializing with them.
Sin is sin. If a believer is committing sin, and they claim to be a Christian, Paul says to not fellowship or socialize with such a person.
"But as it is, I wrote to you not to keep company, if any man who is named a brother is a sexual sinner, or covetous, or an idolater, or a slanderer, or a drunkard, or an extortioner. Don't even eat with such a person." (1 Corinthians 5:11 WEB)
Paul even bluntly states that he judges a man who sins, saying, "For I most assuredly, as being absent in body but present in spirit, have already, as though I were present, judged him who has done this thing." (1 Corinthians 5:3 WEB)
This is appropriate judging. Paul is not being hypocritical by also sinning, and he is objectively calling it what it is: sin.
This kind of judging is exactly what Jesus talks about in Matthew 18, saying, "If your brother sins against you, go, show him his fault between you and him alone. If he listens to you, you have gained back your brother. But if he doesn't listen, take one or two more with you, that at the mouth of two or three witnesses every word may be established. If he refuses to listen to them, tell it to the assembly. If he refuses to hear the assembly also, let him be to you as a Gentile or a tax collector." (Matthew 18:15-17 WEB)
Both Jesus and Paul say to refuse those who claim to be Christian, but are sinners as seen by their actions. Why? Paul explains, "Don't be deceived! 'Evil companionships corrupt good morals.'" (1 Corinthians 15:33 WEB)
Paul further says, speaking about believers who sin, "Those who sin, reprove in the sight of all, that the rest also may be in fear." (1 Timothy 5:20 WEB)
And Jesus says about believers who sin, "Remember therefore how you have received and heard. Keep it, and repent. If therefore you won't watch, I will come as a thief, and you won't know what hour I will come on you. Nevertheless you have a few names in Sardis that did not defile their garments. They will walk with me in white, for they are worthy. He who overcomes will be arrayed like this in white garments, and I will in no way blot his name out of the book of life..." (Revelation 3:3-5 WEB)
Jesus is warning believers that if they do not truly repent and stop sinning, then they risk having their name removed from the book of life. This has always been the message of the gospel, "Repent, for the Kingdom of Heaven is at hand!" (Matthew 3:2 WEB) Simply put, "no repentance" means "no kingdom of God for them."
And what does Jesus says about repentance? "Every tree that doesn't grow good fruit is cut down, and thrown into the fire. Therefore, by their fruits you will know them. Not everyone who says to me, 'Lord, Lord,' will enter into the Kingdom of Heaven; but [only] he who does the will of my Father who is in heaven. Many will tell me in that day, 'Lord, Lord, didn't we prophesy by your name, by your name cast out demons, and by your name do many mighty works?' Then I will tell them, 'I never knew you. Depart from me, you who work iniquity.'" (Matthew 7:19-23 WEB)
According to Jesus, there are those who will prophesy, exorcise demons, and do mighty works in the name of Jesus Christ, yet they will not be allowed entrance into the kingdom of heaven due to their lack of repentance. As Jesus just said, prior to this passage, "How narrow is the gate, and restricted is the way that leads to life! Few are those who find it." (Matthew 7:14 WEB)
Interaction with unbelievers may be necessary in order to be a witness for Jesus Christ. However, as Paul says, "Don't be deceived! 'Evil companionships corrupt good morals.'" (1 Corinthians 15:33 WEB)
Therefore, make a judgment for yourself, and if you feel like their companionship will affect your good morals, then avoid them. As Jesus says of believers in regards to unbelievers, "...let him be to you as a Gentile or a tax collector." (Matthew 18:15-17 WEB)
Meaning, let the "sinful believer" be to you as an unbeliever.
This is not about love, for certainly we are to love everyone. Instead, this is about how we are to respond to those who refuse to repent, as seen by their actions. We still love them, but we do not spend our time with them for the purpose of fellowship.
If the non-believer is overall non-sinful, then fellowship should not be a problem. The issue is when people participate in horrible sins, like sexual immorality, idolatry, being a drunkard, and the rest of the list in 1 Corinthians 5:11.
These are the words of Jesus Christ and the Apostle Paul.
"How narrow is the gate, and restricted is the way that leads to life! Few are those who find it." (Matthew 7:14 WEB)