Clean can mean different things to different cultures, and even to different people in the same culture: clean on a street corner is a completely different thing to clean in a kitchen or a hospital surgery.
So when God starts talking about clean and unclean things for the Israelites, we have to look past the words. It’s more than just the categories of things that are clean and unclean; it’s also about the attitude the Israelites have towards the broader concept:
Any [unclean animal] is detestable to you.
That sounds harsh, but speak to any committed vegan: the idea of eating an animal is indeed detestable. Many people won’t eat whale or dugong or turtle (all unclean for the Israelites), for their own ethical reasons. The very idea is detestable. Indeed, if they ate it, these vegans (and many others) would feel defiled. Chances are, if they started eating whale or even lamb at a vegan meet-up, they would be cast out of that community. They might not describe eating whale as ‘unclean’, but it’s just a matter of the label they choose to use.
For the Israelites, clean/unclean is a label that could have equally been called holy/profane or dedicated/common.
Clean and unclean, then, is not about how grubby something is but how it affects the Israelites in their relationship with each other and with God. It’s about separation from the Gentile (pagan) nations around them.
Some of the food laws look arbitrary to us; part of our problem is that the meaning of some of the original Hebrew words for the names of animals has been lost, so we’ll never be able to really work it out.
It must have been more intuitive at the time. Aaron’s sons broke basic service rules not long after their consecration, and the Israelites had probably flouted just about every other commandment by the time of the exile to Babylon. But there’s no record of Israel breaking the food laws in all that time, and it’s still a mark of separation now.
So the detail is lost, but the meaning remains.
God makes it very clear that the purpose is to demonstrate holiness:
11:45 For I, the Lord, am the one who brought you up from the land of Egypt, that I might be your God. Therefore, you must be holy because I am holy.
The rules, and compliance with them, come about because God had already rescued the Israelites. It is not a means of earning God’s favour. It is a response, and a means of staying in God’s presence.