Why do pigs root into their surroundings?

Pigs will root in the soil, if given the opportunity. This is know as stereotypical behavior and occurs as a natural habit/behavior of the pig. Feral (wild) pigs rut around in the soil looking for something to eat, so domestic pigs do the same. Just like you, as a young child, like to wade through water if it was in your path, rather than going around it.
Prior to the availability of injectable or oral iron supplements, one way for pigs to obtain iron for red blood cell formation was to root in the soil. The soil, in most cases contains iron, adequate to prevent anemia in pigs.