Out of necessity, Severus has become a genius at creating potent magically enhanced soups potions from kitchen waste (fruit or veggie peels, animal bones, scraps of herbs etc.).
When he finds out about Harry's abuse, and is being actively stopped from intervening, he does the only thing he can think of: he makes Harry copy all the recipes in detention, and makes him read "foraging the forest" and "what is safe to eat"-type survival books.
Maybe part of the teachings is also a [magical method, i.e. potion or spell] that can make most things consumable by removing the toxins from it as long as it hasn't totally fallen to decay.
It's the reason why the trio didn't starve to death on the run, and they were not reported to have gotten sick.
It also comes back to Severus by saving his life through one of those "potions", and/or through the detoxifying spell which Harry uses on him in desperation.