Leviticus 11:40
And he that eateth of the carcase of it shall wash his clothes, and be unclean until the even: he also that beareth the carcase of it shall wash his clothes, and be unclean until the even. And he that eateth of the carcase of it shall wash his clothes, and be unclean until the even: he also that beareth the carcase of it shall wash his clothes, and be unclean until the even.
Leviticus 11 is the law given through Moses that defines clean and unclean animals and forbids eating what is classed as unclean, including swine's flesh and the flesh of certain other animals. The carcass rule belongs to that law and to its restrictions on Israel's use of animal food, barring for food animals that died on their own or had been torn. It requires anyone who eats the carcass covered by the law, and anyone who carries it, to wash his clothes and be unclean until evening.
The restriction was given as part of Israel's training in the wilderness in health and sanitary laws to preserve health and life, not as arbitrary control. The forbidden flesh harms health and is not the best food, with swine's flesh specifically forbidden for that reason. Such food fills or pollutes the blood with impurities and shortens life, which is why God specified animals unfit for food. God left the requirement as He gave it, but the Pharisees perverted it by extending it beyond what was required through human traditions and multiplying restrictions until the rules became burdensome. They went to unwarranted extremes, even requiring all water used to be strained lest it contain the smallest insect that might be classed with the unclean animals.
The food appointed at the king's table in Babylon included those unclean meats, along with rich foods and wine that would not keep mind and body in the best health for God's service. Eating the king's meat would therefore defile Daniel, so he and his three companions refused it in obedience to God's will as the supreme law of life despite risk to position and prospects. Their refusal was to honor and glorify God, to perfect character, and to keep clear intellect and physical strength to stand as representatives of the true religion amid heathen false religions. They practiced temperance in eating and drinking so as not to enfeeble brain or muscle, kept mental powers clear and undimmed, treated physical health as a matter of highest consideration, and would not imperil physical and moral powers for indulgence of appetite, making decided effort against temptation and trusting God with the rest.