Okay - there’s a few different things here. Many of the food laws may have originally been a list of what things were safer to eat (eating shellfish, for example, can kill people if the shellfish have spoiled before cooking; pork can make people sick if it hasn’t been properly cooked, etc.), but they, along with the other ritual purity laws became a way to show that this was a “people set apart for God”.
However, as for punishments for certain sins, it seems to me that these punishments were to show the true horror of the given sin. The early Israelites didn’t have a very clear idea of the afterlife (actually, pretty much not believing in one at all, unless you count Sheol, the “abode of the dead” as an afterlife, but it’s considered synonymous with “the grave”). This also shows why many seem confused in the OT about why the evil often prosper in the world, while the righteous often suffer. Death and illness were considered punishment for sin (the righteous were expected to live longer than the wicked), and if one’s sins were scandalous, it was the duty of the people to remove the scandalous person from their midst. But… in a way, it’s God dictating to a people the horrific nature of sin because they can’t fathom the idea of an afterlife and justice in the next life. Notice that almost all of the sins listed as deserving death are mortal sins. For us, we leave the judgment up to God, and allow the person to repent. But in the time of the early Israelites, who had no such notions about an afterlife, meting out punishment in the here and now was the only way to display the wretchedness of sin.