Within the intricate legal framework of the Old Testament, particularly in the Torah, what was the primary theological and societal purpose behind the laws concerning gleaning (leaving leftover crops for the poor and foreigners), as exemplified in Leviticus 19:9-10 and Deuteronomy 24:19-22?