the self-image of israel in the pentateuch is of a pure and godfearing people, and maintaining racial/ritual purity is how Moses makes all his stuff stick if he can’t provide a story of someone being smited.
there is remarkably little sympathetic magic of this frazerian type explict in the pentateuch, but maybe not surprising because in these ochre-coloured books, israel makes a living through herding, harvesting manna (sometimes quail) and looking forward to “a land for which ye did not labour, and cities which ye built not, and ye dwell in them; of the vineyards and oliveyards which ye planted not do ye eat”.
to be sure, the law against sodomy is included with the law against bestiality, but even then it seems more about the perversion of mixing natural kinds more than the sympathetic spreading of infertility-qua-infertility.
i mentioned in some previous post where someone mentioned the “the halacha is an instruction manual for running an agricultural society” how this rang false to me because not only were there many thriving agricultural societies that weren’t run on halachic principles, but the halacha makes no claim like this: it defines itself against these materially thriving societies, and does not claim, much, to be materially and rationally better – the superiority it claims over and over again is that it is a code for preserving one particular superior breed of mankind, YHWH’s people, so long as it followed a supernatural law.
after all, Canaan was a land flowing with milk and honey before Israel got to it so whatever promiscuity and perversion they were getting up to, that was hardly having any effect on the land