One of the worst and most dangerous temptations is to doubt God’s goodness. Even if you don’t understand something (which happens to us all, in fact I don’t know why exactly the demons were cast into those pigs) - it’s important to trust in God’s wisdom and goodness, because we know this for a fact. If you’re doubting this, just look at the Cross, and look at Christ who bled and died for you - would He do this if He did not love you? So He is Love and loves us more than it’s possible for anyone to love… so everything He did, He did to help us He also loves His creation, but He came to earth to save our souls, because our souls are eternal and can be saved or lost… what a great loss He feels, when a soul is lost, - the soul that He redeemed at the cost of His own Blood, and suffered such tortures for! He would do it all again for that soul. If you focus on that, that will give you more understanding, because often we can only understand God’s ways when we trust and love Him because this is something that comes to us through grace, and something that is communicated to us… if we don’t open up to God with trust, we are blocking anything He wants to give us, such as understanding, if that is His Will. But if it continues to be unclear why this happened to the pigs, - just continue to focus on Our Lord, and someday in Heaven, you might know, but the most important part is being with Him I undertstand that this is probably really bothering you, but instead of coming to it from the perspective of the pigs, - think first of God’s goodness and trust in that, and that could really help. I had a similar thing with God’s existence and the reality of evil in the world… I looked at the evil in the world, and began to doubt God’s existence because I wasn’t aware of how theologians and Saints have explained it over the centuries. Once I learned their explanations, they made so much more sense than the atheistic points. But I found that I could understand these explanations from the Saints better when I was closer to God and opened up more to Him, because He helped me to understand… and this is something that we need TRUST for.
God made the earth and the animals and the sun and the stars - with so much love, because He is Love, and He did it in a way that brings glory to Him, - and He gave us all these things. Animals are wonderful and I love animals too. But He made you in His image which is even greater, much greater. He gave you an eternal soul to be in union with Himself forever. This is something that we can’t really imagine, and the more we learn about it, the greater it gets. He gave you reason, free will, and an individuality that cannot be repeated, and a mission in life that cannot be repeated by anyone else, ever. Then, He came to earth for you, which is more significant than if any of us were to become a worm. He left infinite glory in Heaven to continually suffer, in many ways that most people do not know, and then be killed by His creatures, and nailed to a Cross… He did all this for each soul, and for you. If you look at the Crucifix, you can see God’s Love there. If after this, there are points in the Gospels that are not clear, like about the pigs, - you can still say to God - “I don’t understand why this happened, but I know that You are Good, and You are Love, and Wisdom, and I trust in everything that You decided to do. Your Will be done on earth as it is in Heaven”.
God bless you!