Dogs and swine in this context are those who are hostile to the gospel i.e. the good news. There are many who hear the gospel, but do not receive it and even mock the once sharing the truth of salvation through Jesus Christ. The Pearls of the precious gospel is foolishness to those who do not want to believe. They are blinded by the god of this age (2Cr 4:4). The gospel is foolishness to them: "But the natural man does not receive the things of the Spirit of God, for they are foolishness to him; nor can he know them, because they are spiritually discerned." 2Cr 2:14. Instead of receiving the gospel with joy as many, they ridicule and reject the good news of salvation and eternal life. Jesus is basically saying, don't waste your time on those who will not hear, they are too blind to see and they do not want to come to the knowledge of the truth but in return mock and ridicule the Christian who shares with them. This should not discourage us from sharing the gospel, but if rejected over and over again by the same person(s) we are witnessing to, than we need to know when to stop and let the Holy Spirit do the work on that persons heart, we ourselves can not save anybody, it is God that saves. We can only share the good news and know when to step aside, we might miss another opportunity witnessing to someone with an more open heart. There are many that are seeking the truth, the truth is in Jesus Christ and what He has done for us. He paid our penalty that was due, because God loved us even when we were yet sinners. He demonstrated His love for us at he cross.
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life." John 3:16