I think it relates to the fact that pigs and humans have to eat the same thing. Cows, horses and etc can digest cellouse and humans and pigs can't. During a famine people would be pretty upset if you were the owner of pigs...whether you were the king or not, hungry people will kill you because they know you're feeding the pig something you could be eating.
Religious leaders probably recognized the potential for conflict and worked this prohibition into the religious texts.
Also, cattle are 75% more efficent at digesting cellouse than horses and archaeologists use the ratio of horse/cow bones to detect drought/famine conditions, especially out on the steppes.
I think the food laws begin with Leviticus 11 — animals which go on the cloven hoof and chew their cud, and not animals which lack one or the other, are permissible; more detail is in Deuteronomy 14:3-6.