Pigs are no more impure than dogs, fwiw. That belief is merely a result of having been raised in a culture that arbitrarily chooses to love dogs and cats and hate most other animals.
Dogs can be infested with parasites just as easily as pigs.
This rule was written in an age when rabies was a big problem. It has a lot of sense to avoid scavenger dogs and pigs in those places in the past. Now we have developed a solution to this problem but, as is included as part of a religion is a fossil rule that can't be changed. We have still many of this rules around.
Science welcomes change when we find a better way to do something. Is assumed that humans can be wrong and learn. Religion will fiercely oppose change because god can't be wrong by definition (and nobody has the authority to fix it). Ideology will oppose also changes that see as a menace, but can be more flexible.
In Judaism at least, and I'd assume the same translates to Islam, "impurity" is understood to mean "ritually impure". It doesn't necessarily mean there's a specific scientific reason to avoid the meat, just that God asked them not to partake.
Yeah, ritual impurity is forgotten in modern West and hard to describe to a modern non-religious person.
It is not the same as "being unhygienic", though it overlaps to some degree. (Faeces etc.)
An interesting example from Judaism is "Tzaraath", which means skin disease, but it could also afflict houses. Today we do not know for sure what it even meant. Mold infestation? Maybe.
“Dogs are pets” is one of those cultural background assumptions that can be pretty jarring when you realize it’s not a universally held belief. There are pretty large chunks of the planet where dogs are mostly unwanted pests at best.
It’s not a religious thing, it’s a geographic thing. Wild dogs are a serious problem in some areas, and whether or not dogs are viewed as common pets varies wildly. To pick one example, a mere 16 million homes in India have a dog, and that is up a lot over the past decade. Compare that to the 63 million homes with dogs in the US, a much smaller country by population.
Dogs can be infested with parasites just as easily as pigs.