Some taboos definitely serve a societal function because the act itself is detrimental to society, for example incest, which has certain genetic downfalls. Or any kind of murder, but especially something like matricide is taboo because of the familial connection. Other taboos like bestiality, sodomy, or any disgusting habits might have evolved out of a sense of sanitation or health. Personally I lean towards one specific answer for why taboos exist, and its neither wrong nor right but just my first instinct/guess. I think they exist because life is complicated and hectic enough without people going around doing wierd crazy stuff to make it even worse. So we all collectively decide we aren’t in favor of something, like necrophilia, and then it sort of becomes taboo to go and do THAT. And maybe that taboo discourages some people, and maybe that helps us all a little bit.