The story
The three foods are metonyms for those things suitable to each of medieval society’s classes of people; fish represents the clergy, flesh represents commoners, whilst red herring represents paupers; the three classes are simplistically regarded as exhaustive.
Etymology from Wiktionary, CC BY-SA 4.0.