The name comes from the thin translucent layers you see when you peel an onion. On paper, animators literally stacked semi-transparent sheets over a lightbox to see the previous drawing through the new one; digital tools (TVPaint, Toon Boom, Procreate Dreams, Krita) reproduce this as a layer setting.
The previous frame is usually tinted red and the next tinted green, so it's instantly clear which is the past and which is the future. That makes it easy to catch a common mistake — "noodle arms" that drift back to the same spot every frame instead of following a clean arc.
How many frames ahead and behind to show (the onion-skin range) depends on how fast the action is; faster motion needs more frames stacked to read the arc at all.
When to use
Stacking too many frames at once just creates noise — one or two frames on either side is usually enough.