I also like to shake my legs. I heard it from my psychology teacher before. At that time, it was a test, which said, "Imagine a sunny afternoon in a very comfortable cafe, leaning against the window, drinking coffee and listening to a friend sitting opposite." What kind of action are you most likely to have? 1. Shake your legs. Step 2 stare at each other. 3. Look out the window. 4. Hum a song and stir the coffee .. "I can't remember the rest.
I remember the teacher said that shaking your legs is similar to shaking your ears, which means that you are actually receiving some information, thinking and digesting.
But I personally think it has something to do with sitting posture and the height of tables and chairs.