What the heck do fermented foods have to do with sleep? Fermented foods promote a healthy gut, and a healthy gut is a prerequisite for our bodies to feel at ease. In fact, there's a direct line of communication between our gut and our brain, called the vagus nerve. When the brain is relaxed, it gives the gut permission to devote energy toward digestion. Conversely, if we're running from a tiger and in a panic, it tells the gut, Hold off on that for now; we have other things to worry about.
Meanwhile, the vagus nerve also carries information from the gut to the brain. If the gut is inflamed (maybe you've eating something you don't tolerate, or the gut ecosystem has gotten out of balance after a course of antibiotics), then the vagus nerve tells the brain: feel uneasy. This can make us feel anxious or depressed during the day and sleepless at night. Perhaps it's designed to motivate us to change our behavior. Ate pizza → felt uneasy → maybe I shouldn't eat pizza. Unfortunately, pizza hits our brains like a drug, so as with any other drug, cravings can trump our awareness that something is making us sick.
Examples of fermented foods include sauerkraut, kimchi, apple cider vinegar, beet kvass, miso paste, lactofermented pickles, yogurt, and kefir (if you tolerate dairy).