All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
Allaah Says (what means): {Prohibited to you are dead animals, blood, the flesh of swine,…}[Quran 5:3] Then Allaah Says (what means): {But whoever is forced by severe hunger with no inclination to sin — then indeed, Allaah is Forgiving and Merciful.}[Quran 5:3] There are several verses in the Quran that have the similar meaning.
In brief, pork is forbidden because of the various harms it can cause and because of its impurity. But if a person finds himself in case of necessity to eat pork in a way that he fears death if he does not eat from it, then it becomes lawful for him to eat the minimum necessary. This is lawful because preserving life is one of the principles which Islam preserves. These principles are preserving the religion, the life, the mind, the progeny and the wealth.
Allaah Knows best.