According to the Huberman podcast, simply elevating your legs at night can improve the glymphatic system's ability to clear out junk from our brains. I haven't been able to find any links to actual studies on that though.
Wouldn't it be elevating your head, rather than your legs? Most sources I've seen[1] that discuss inclining your bed have your head be higher up than your legs.
When your foot is swollen from a sprained ankle people recommend elevating it to "drain" it (I'm not sure if that is the real explanation for why, could just lower blood flow and not drain anything).