Any repetitive, stereotyped behavior that seems to have no immediately apparent purpose is known as...

A compulsion or repetitive behavior.