Matthew 7:1-7Judge not, that you be not judged. For with the judgment you pronounce you will be judged, and with the measure you use it will be measured to you. 3 Why do you see the speck that is in your brother’s eye, but do not notice the log that is in your own eye? 4 Or how can you say to your brother, ‘Let me take the speck out of your eye,’ when there is the log in your own eye? 5 You hypocrite, first take the log out of your own eye, and then you will see clearly to take the speck out of your brother’s eye.6 “Do not give dogs what is holy, and do not throw your pearls before pigs, lest they trample them underfoot and turn to attack you.
What is Jesus talking about here? He’s saying that even after you have taken the beam out of your own eye, you may want to NOT speak to certain people about spiritual matters because in a spiritual sense, they are pigs and dogs. How can He say such a thing right after "judge not"? Because that’s only one side of the truth here – and taking one side of a profound truth is always heretical. Here’s what John Wesley said about the above passage.
Yet even then, when the beam is cast out of thine own eye, Give not – That is, talk not of the deep things of God to those whom you know to be wallowing in sin. neither declare the great things God hath done for your soul to the profane, furious, persecuting wretches. Talk not of perfection, for instance, to the former; not of your experience to the latter. But our Lord does in nowise forbid us to reprove, as occasion is, both the one and the other.
Here’s Albert Barnes’ commentary:
Dogs signify men who spurn, oppose, and abuse that doctrine; men of peculiar sourness and malignity of temper, who meet it like growling and quarrelsome curs, 2Pe 2:22 Re 22:15. Swine denote those who would trample the precepts under feet; men of impurity of life; corrupt, polluted, profane, obscene, and sensual; who would not know the value of the gospel, and who would tread it down as swine would pearls, 2Pe 2:22 Pr 11:22. The meaning of this proverb then is, do not offer your doctrine to those violent and abusive men, who would growl and curse you; nor to those peculiarly debased and profligate, who would not perceive its value, would trample it down, and abuse you.
And John Calvin:
Christ appears to distinguish between the swine and the dogs: attributing brutal stupidity to the swine, and rage to the dogs And certainly, experience shows, that there are two such classes of despisers of God. Whatever is taught in Scripture, for instance, about the corrupt nature of man, free justification, and eternal election, is turned by many into an encouragement to sloth and to carnal indulgence. Such persons are fitly and justly pronounced to be swine Others, again, tear the pure doctrine, and its ministers, with sacrilegious reproaches, as if they threw away all desire to do well, all fear of God, and all care for their salvation.