It was probably considered impure because pigs have a big parasite issue before industrialization and improper cooking often led to people getting sick or dying.
A lot of religious "rules" can typically be boiled down to trying to keep people alive by making sure they avoid potential dangerous things, increasing their hygiene, or just making life easier and reducing hardships.
It's almost like people in charge realized that it would be easier to get people to do things if it meant going to heaven and avoiding hell instead of jail or something.