Colloquially, we may refer to non-kosher food as “treif,” but that term has a much more specific meaning. A treifah is literally an animal that has been mortally wounded, the Hebrew root TRF meaning torn. The basic case is that a wolf or some other predator attacked a domestic animal and left it in such a state that it will surely die from its injuries. Such an animal may not be preemptively slaughtered. (This law only applies to a mortal wound; if a lion whacks off your sheep’s tail, it will survive that attack and it is not a treifah.)
As with other mitzvos, the scenario given by the Torah is not meant to be exclusive; it is merely a common way that an animal might get such an injury. In practice, it doesn’t matter how the animal was wounded, it just matters that it was wounded.
The reason for this mitzvah is explained by the Sefer HaChinuch using the analogy of a blacksmith and his tongs; I am going to reframe his ideas using my own metaphors. In short, the body is a vehicle for the soul and we have been given a user’s manual for taking care of our equipment. Just as we might eat things that are physically poisonous, it is also possible to eat things that are spiritually poisonous. Medical science may not be able to identify the dangers of spiritual toxins, but God is the Ultimate Doctor and He has warned us away from things that are hazardous to the health of our souls. (The Chinuch goes on to say that God does not detail the nature of these spiritual diseases because that would cause people to try and justify why such things don’t apply to them and then ignore the kosher dietary laws. As we all know, many people would later claim that kashrus was for health reasons and that, for example, since we have conquered trichinosis, it should now be okay to eat pork. In short, the Chinuch nailed human nature on this one.)
An animal doesn’t have to suffer such an injury in an attack or even in an accident for it to be a treifah. Even if the animal develops the injury as a result of natural causes, it may not be eaten. The Talmud (Chulin 42a) identifies eight major categories of treifah and many sub-categories. The common occurrence of treifah injuries in lungs leads to our practice of “glatt kosher” meat. (“Glatt” is Yiddish for “smooth,” i.e., free from any potentially problematic pulmonary adhesions. Only meat can properly be referred to as “glatt.” The finest wine, cheese and crackers can never be “glatt” as the grapes, milk and wheat from which they were made didn’t have lungs to inspect!)
After telling us that we may not eat meat from a mortally wounded animal, the Torah says, “throw it to the dogs” (in the verse already under discussion, Exodus 22:30). We may not eat such meat, but we may have hana’ah, benefit, from a treifah. A Jew is permitted to feed it to his animals or to sell it to non-Jews (who are permitted to eat it). This is not necessarily the case with all prohibitions; some we are permitted to benefit from, others we are not.
This mitzvah applies to both men and women in all times and places. It is discussed in the third chapter of the Talmudic tractate of Chulin, starting on page 42a, as well as in Makkos (18a) and Bechoros (3a). In the Shulchan Aruch, it is codified starting in Yoreh Deah 29. This is #181 of the 365 negative mitzvos in the Rambam’s Sefer HaMitzvos and #87 of the 194 negative mitzvos that can be fulfilled today as listed in the Chofetz Chaim’s Sefer HaMitzvos HaKatzar.