Why do people often do unnecessary things while performing a main task? And this is not about procrastination (I'm almost certain).

I've been noticing it since childhood that people (me included) tend to do unnecessary side activity, especially if they're invested in the main activity.

Examples of main activity: having a thoughtful conversation, watching an interesting movie, crafting something manually.

Examples of side activities: doing tricks with a pen, playing with shirt buttons, doodling, tearing a piece of paper into smaller parts, attaching and detaching magnets, in other words almost anything slightly amusing/interesting/touch-pleasant.

The side activity tends to increase with the intensity of main activity, only ceasing at the point where the main activity takes all the concentration a person can manage to attain.

What causes this? Does it somehow help us perform the main activity? Then how exactly? Or is it a reaction to performing something effortsome?
In the whole scheme of human consciousness, these movements may be a result of what one individual person's autonomic and central nervous system has been conditioned to expect. While awake during different hours of different days, implying different variables to be present depending on [social code] etc, our central nervous system (CNS) has a threshold for response- the level of response/arousal to sensory input accompanied by these variables stated above will ultimately help someone read what their basal level of arousal is. If that basal level arousal is not met in a certain social context (this basal level has increased via techna-cultural advancement) than the body may expend this energy via other methods of movement or concentration.