The other night, while I was out playing pool with my wife, I suddenly realized I was dancing back and forth from one leg to another in that ever-so-familiar pattern that indicated I needed to go to the bathroom. Badly.
Since almost all situations I experience ultimately lead me to thinking of Straight Dope, I found myself wondering what exactly our bodies are doing in this situation. Why do we hop around like that? I figure that if it were a simple distraction method, it wouldn’t be so universal among us, so I’m assuming there’s something more to it than that.
Please, enlighten me!
Presumably, you witnessed this behavior from someone else. And thus, the meme spreads.
It relieves the urge a bit, presumably by pressing on a nerve or easing the pressure or something along those lines.
Intestinal gass can put pressure on the bowels & bladder, leading to a “need for speed”. 
Jiggling around can release internal gas, thus reducing pressure, & delaying the need for release.
I honestly don’t know but the “need a wee” dance is very obvious!
Every day I say “do you need a wee?” The answer is mostly “NO” followed by a really fast run to the loo!
The wee dance is a wonderful thing!
I don’t do it. It could be cultural.
Just a WAG, but from my experience one does the “potty dance” for the same reason one shakes, rubs, or otherwise nurses an injured body part: It distracts from the discomfort by giving your body something else to occupy itself with – preferably in the immediate region of the concerned area. If you smack your thumb with a hammer you’ll likely alternate between shaking it around, sucking on it, and/or grabbing/rubbing it with your other hand. All of these things introduce additional sensations in the affected area which serve to divert some of the attention away from the injury and on to whatever activity it is you’re doing. The immediate contrast between doing these things and doing nothing is obvious: If you just sat there doing absolutely nothing after smashing your thumb, it would hurt like nobody’s business because all of your attention is focused on the pain.
Similarly, wiggling one’s hips, shuffling from foot to foot and general fidgeting keep your body busy and your mind at least partially off the business you’re trying very hard not to do in mixed company.
That’s my guess anyway.