Google is your friend.
"The phrase implies that they're better off doing something stupid than bothering you. It expresses an additional level of disdain and contempt than by just saying, “go away!”
According to some, it has a military origin.
"Pounding sand (or ground)" equates to marching...