Ahh...be careful not to take portions out of context...as you just did. When you read the following verses, things are put into perspective, no?
"Judge not, that you be not judged. For with what judgment you judge, you will be judged; and with the measure you use, it will be measured back to you. And why do you look at the speck in your borther's eye, but do not consider the plank in your own eye? Or how can you say to your brother, 'Let me remove the speck from your eye'; and look, a plank is in your own eye? Hypocrite! First remove the plank from you own eye, and then you will see clearly to remove the speck from you brother's eye." Matthew 7:1-5
Furthermore, when you understand what verse 6 is saying, you will see that it goes hand in hand with what Paul is saying in 1 Corinthians 5.
"Do not give what is holy to the dogs; nor cast your pearls before swine, lest they trample them under their feet, and turn and tear you in pieces." Matthew 7:6
While it is not an easy portion to understand, when you do, you will see that Paul was mirroring exactly what Jesus said, just in a way that could be more easily understood by those who weren't familiar with Jewish expressions. The point is that 'what is holy' and 'your pearls' refers to the value of rebuke (or condemnation) to a true believer (one who is 'wise' in the words of Solomon). The dogs and swine refer to those who are not believers, or as Solomon refers to such in Proverbs, 'fools'. And speaking of Proverbs, there are many portions that refer to 'rebuke' and how the 'wise' and the 'foolish' receive such. One such portion that is readily applicable is in Proverbs 25:12:
"Like an earring of gold and an ornament of fine gold is a wise rebuker to an obedient ear." Proverbs 25:12
Again, you stopped your quote of 1 Corinthians 5 too short and lost what was truly being said.
For what have I to do with judging those also who are outside? Do you not judge those who are inside? But those who are outside God judges. Therefore "put away from yourselves the evil person." 1 Corinthians 5:12
What happens when blatant wrongdoing is allowed to go on without any sort of deterrent? It gives the impression that that wrongdoing is condoned. This is not the impression that should be given.