May a Muslim eat forbidden food when his life is in danger?
Yes. To save a life it is not only permitted but actually required. One should, however, take only as much as is strictly necessary to survive.
Islam places a very high value on human life. The dietary laws are meant to serve people, not to endanger them. That is why the verses above, which list the forbidden foods, both end with an exception. Whoever is driven by necessity commits no sin.
Imagine someone who is lost or cut off and can find nothing to eat except something forbidden. If he does not eat it, he will die. In such a situation it is not merely permitted to eat it. It is his duty to preserve his life.
The exception, however, has a clear limit. The verse speaks of someone who is neither disobedient nor exceeding the limit. This means taking only the bare minimum, just as much as is needed to survive. Necessity is not an opportunity to eat one’s fill of what is forbidden.
Here we see a basic feature of Islam. Its commandments are clear, but they are not rigid. They take a person’s situation into account, and God is most forgiving and merciful, as the verse itself says.