Milling around

Milling around -- does anyone know the origin of this phrase? What does aimlessly hanging about have to do with grinding grain?

It's the circular motion. Milling is not random motion; it's moving in a circle, aimlessly. There's even a specific procedure to keep cattle from stampeding by "millng" them: getting them to move in a circle that calms them down.