The disciples, who have already been exhorted to love their enemies (5:43-47) and not to judge (v.1), might fail to consider the subtleties of the argument and become un-discerning simpletons. This verse guards against such a possibility.
"Pigs" and "dogs" serve together as a picture of what is vicious, unclean, and abominable (cf. 2 Pet. 2:22). The pigs trample the pearls under foot (perhaps out of animal dis-appiontment that they are not morels of food), and the dogs can be so disgusted that they turn on the giver. So the aphorism forbids proclaiming the "sacred" Gospel of the kingdom to certain persons designated as dogs and pigs. Rather than trampling the Gospel under foot, everything must be "sold" in pursuit of it (13:45-46).
This verse is not a directive against evangelizing the Gentiles, especially in a book full of various supports for this. "Dogs" and "Pigs" refer to any persons who have given clear evidences of rejecting the Gospel with vicious scorn and hardened contempt.
[NIV BIBLE COMMENTARY Volume 2: New Testament].
JESUS IS LORD.