The exact origin of unclean animals has varied among scholars. The most popular two opinions are in relation to the hygiene of the animal and the literal health-risk from eating it while the counter opinion is to deter men from the majority of animals which were made into symbols of sin or used for idol worship (ie: idol sacrifice animals to false gods).
The first mention of unclean and clean animals are just prior to the flood when we see that God says to gather 7 of every clean and 2 of every unclean animal into the ark. The reason why things became clean or unclean seems to be unknown though for certain. We do know that animals were used in sacrifices after the fall of Adam & Eve with their sons Cain & Abel, but we don't see any mention of them being eaten until much later. Adam and Eve may have been vegetarian prior to fall as suggested by Genesis 1:
Genesis 1:29 Then God said, "I give you every seed-bearing plant on the face of the whole earth and every tree that has fruit with seed in it. They will be yours for food."
After the fall, God curses the ground and tells Adam that he will continue to eat the plants of the field with no mention of meats.
Genesis 2:19 Cursed is the ground because of you, through painful toil you will eat food from it all the days of your life. IT will produce thorns and thistles for you, and you will eat the plants of the field. By the sweat of your brow you will eat your food until you return to the ground, since from it you were taken; for dust you are and to dust you will return.
So even after the fall, we still do not see any mention of the clean and unclean animals being consumed. Now, fast forward a bit and we have Cain and Abel. Abel had a flock and offered the fat portion to God as an offering. We also have the first atonement sacrifice introduced by God to Adam when God kills an animal to create clothes for Adam and Eve.
Being that Abel was a keeper of a flock, we also must assume there was a purpose to keeping a flock. In modern-day we would assume a meat-eating lifestyle, but given that the people were vegetarian, the purposes of sheep and goats could have extended to milk, cheese, clothes, etc. In the desert area that they lived the milk would go sour quicker and thus it would be constantly used for drinking as well as turning into cheese. Abel's mom, Eve, gave birth to 33 sons and 23 daughters total according to the works of Josephus in the footnotes of Chapter 2 in Jewish Antiquities (a famous Jewish historian scholar 30-100AD), this would require a significant amount of clothing to be made and thus flocks would have been crucial as a source of milk, cheese, clothing as well as making sacrifices to God.
Fast forward about 1000 years and we have Noah. There is also a fantastic parallel here between Noah (post-flood) and Adam (pre-fall) that may give us some insight as well:
Genesis 1:28 God blessed them (Adam and Eve) and said, "Be fruitful and multiply and fill the earth and have dominion over the fish of the sea and over the birds of the heavens and over every living thing that moves on the earth."
So previous to the fall in a sinless world, Adam and Eve are told to populate the earth and they have dominion over everything, but to keep a vegetarian diet (Genesis 1:29).
Genesis 9:1-3 God blessed Noah and his sons and said to them, "Be fruitful and multiple and fill the earth. The fear of you and the dread of you shall be on every beast of the earth and every bird of the heavens upon everything that creeps on the ground and all the fish of the sea."
Genesis 9:3-4 Everything that lives and moves will be food for you. Just as I gave you the green plants, I now give you everything. But you must not eat meat that has its lifeblood still in it.
Now after the flood in a sinless world, Noah and his family are to populate the earth and everything will run from them, but they can now eat everything that lives and moves. However, it is important to note that not all green plants were edible, there were poisonous plants, deadly plants, mushrooms, etc. So it was only of the edible plants that Noah could eat from, and thus reasonably it would make sense that Noah likewise would only eat the edible animals and parts of animals that were edible. If God had determined for us what edible foods were through instruction of what was sacrificed to God, then "all the plants" and "all the animals" would have meant "all the edible". This is essentially the first time people are able to eat meat. Previous to Noah, there is no mention of eating meat. There are sacrifices of clean animals, but no mention of meat being eaten - the meat was for God, the clothing and milk was for the people - It's possible that the logic of clean and unclean in sacrifice moved into what is food; for example: what is good enough for God in sacrifice must be good for us as food.
The generations spread and eventually we bump into Abraham about 500 years later. There are mentions in Abraham's story (Genesis chapters 11-26) of clean animals being eaten and sacrificed, but no unclean animals are mentioned being eaten or sacrificed. So it is once again reasonable to assume that Noah and his descendants understood that food pertained to specific characteristics of animals - there were animals who were unsanitary, not suitable for sacrifice, and were not considered food, and there were animals who were considered food.
We then have the rest of Genesis happen (which is a LOT) and then all of God's people become slaves in Egypt. Due to whatever reason; possibly extended time in a pagan country blending with oral traditions, they had possibly lost sight of what was considered clean. When Moses went up to Mount Sinai to get the laws from God, the people were so desperate to obey God's commands that they didn't eat any meat and loaded up on cheese which they knew was safe. This cheese-filled holiday is known as Shavuot and is still celebrated by Jews, Hebrew Roots Christians, and Messianic Jews today. So it seems as though there was some question at one point as to what is clean but whether or not which animals were questioned is unknown. It could be that the Jews knew which animals they could eat, they just didn't know what parts or perhaps if they needed to sanctify it somehow first.
Once the written clean/unclean laws were in place, they were not even questioned until after Christ's ascension. If it was not on the list, it was not food. Those who ate it were going against the commands of God and also eating unsanitary garbage. If someone ate a pig, they would see it is no different than someone enjoying a branch of poison ivy. Just because you CAN eat it, does not mean it is edible and that was the reasoning.
There is one common trait among the 'unclean' animals though, they are the janitors of the earth. They eat the dead, the garbage, feces, feed on the unclean, and are essentially the vacuum cleaners for earth. For more info on if the food laws are still applicable to us, check out the Is it Wrong to Love Bacon? article