Allah (SWT) creates everything with a purpose and reason. Pigs were not created to be eaten by man, rather, Allah created pig's during Hazrat Nuh's (Noah of theArk) time, because after the flood the land was full of dirt and the pigs were created to eat all the dirt away.