Whips have been around in one form or another for as long as recorded history. Look at some reproductions of hieroglyphics and you’ll see that many depictions of rulers show them with their arms crossed across their chests holding in one hand a staff or religious symbol and in the other a whip. Not the kind of whip we know today as a Bullwhip or Stockwhip, but a long handle with strands attached (this was strictly for punishment).
The purpose of using a whip in driving animals (herds of cattle or teams of horses) is to steer them by frightening them with the sound. You are never supposed to hit the animal. That would spoil the hide and possibly cause the animal to rear and cause a stampede. Modern cattle and horse ranchers in the US rarely use a whip (helicopters are more effective), but in Australia they are still used.
Whip cracking may in fact date back to the dinosaurs. Based on computer modeling of the skeleton of the Apatosaurus, Nathan Myhrvold, formerly chief technology officer at Microsoft, suggests that it may have been able to crack it’s 41 foot long tail. The tail weighed 3,200 pounds and would have cracked with a volume of about 200 decibels, about 2,000 times the energy of a modern bullwhip. Myhrvold suggests that this may have been a form of sexual display. For more information see this ABC news article or the November 1997 edition of Discover magazine.