We owe this unit of engine power measurement to Scottish engineer James Watt.
In the early 1780s, after making a vastly superior steam engine to the then classic Newcomen steam engine, Watt was looking for a way to market his invention, advertising the fact that his engine used about 75% less fuel than a similarly powered Newcomen, among many other improvements.
At first, he tried selling his engine on a royalty scheme, where the customers would owe him one-third of the money they saved by using his engine over other steam engines. Of course, many at the time used horses, not steam engines, so it was difficult to compare without them actually buying the engine to see how it would perform for their particular usage. Thus, he scrapped the royalty scheme and decided to try a different tact to convince people to buy his engine.
Ever the inventor, his solution was to come up with a new unit of measurement that those in need of his engine understood -horse power, referring to powerful draft horses.
Thus, he set about determining how much power a typical draft horse could generate. It isn't known exactly how he came up with the numbers he did, as there are conflicting accounts of the experiments he ran. But after doing those experiments, he figured out a typical draft horse could do about 32,400 foot-pounds of work in 60 seconds and maintain that power rate for a good long workday. He then rounded up, going with 33,000 foot-pounds per minute for 1 horsepower.
So, in other words, by his estimation a good draft horse could lift 33,000 pounds of material 1 foot in 1 minute or 3,300 pounds of material 10 feet in one minute, etc .
In truth, that's a very generous estimate as very few horses could maintain that kind of power for a full workday, but getting a perfect figure wasn't that important to what Watt was trying to do. Further, by overestimating what a horse could do, whether intentionally or not, he made sure that his product would always over deliver what he said when trying to get people to buy it, which is a great word-of-mouth marketing trick.
In the end, Watt's engine was revolutionary and played a huge role in the Industrial Revolution. Thanks to this fact, his unit of measure of an engine's power, horsepower, also became popular. Funny enough, today the SI unit of power, the Watt, which was named in homage to James Watt, has widely come to replace "horsepower" in most applications.