The connection of this verse to the previous ones is not obvious. Jesus had been speaking about judging in Matthew 7:1-5. Perhaps Jesus is now trying to prevent His disciples from drawing the false conclusion that all judging is wrong. The Lord commands that holy things not be given to dogs, and pearls not be thrown before swine. Obviously, in order to obey this command, some judging is necessary, but what does Jesus mean by these statements?
Let's first state what we know His prohibition does not mean. (1) He does not mean that there are some who should not have the opportunity to hear the gospel. The gospel message is for all; God wants all to come to the knowledge of the truth (Mark 16:15; I Tim. 2:4). (2) He does not mean that we are to predetermine which individuals would be good prospects for conversion. Who would have ever known that Saul of Tarsus, the great persecutor of the church, would be an ideal prospect for Christianity (Acts 9)? (3) He does not mean that we are to have a self-righteous attitude and withhold the gospel from those who aren't "righteous" like us. We are to esteem others as better than ourselves and look out for their best interests (Phil. 2:3,4).
Now that we've mentioned some common misconceptions on this passage, let's talk about what Jesus does mean in this verse. Quite simply, Jesus is warning us that certain things cannot be given to some individuals or types of persons. Specifically, He means that we should be wise in our attempts to preach to individuals who thrust the gospel away and reject it. When we encounter individuals who don't want anything to do with the gospel, we should "shake the dust off our feet" (Matt. 10:14) and go to those who want it. We can't do this without making a judgment!
It is a foolish waste of precious time to try to force the gospel on those who resist it, for they do not understand the beauty or value of it, and persistent presentation of it only provokes their anger! Nevertheless, in order to determine whether or not one actually will reject the gospel, they must first be given a chance to hear it. To judge one on the basis of physical appearances or habits and conclude that they would not be interested in the gospel is premature judgment and wrong! Let us strive for a humble attitude as we preach God's saving gospel to all, but let us also cherish and respect the preciousness of it by not forcing it upon those who reject it and are unappreciative of our efforts (i.e., the dogs and hogs of our day). For New Testament examples of this, please study: Acts 13:42ff; 19:9; Matt. 21:23-27.
Friends, although we are not to judge vengefully, unmercifully, or hypocritically toward our fellow man, there must be some discerning of character based upon the evidence at hand (cf. Matt. 7:20). May God give us wisdom in this regard!