The very earliest horns were hollowed-out animal horns, or other natural objects that would resonate at a particular pitch when the player buzzed the lips against a hole in one end.
The modern instrument is descended from earlier brass instruments that were used for centuries in Europe for military and hunting purposes. These horns came in various different sizes and shapes. The orchestral horn is particularly descended from the French trompe de chasse; hence the name "French horn". This hunting horn, in use in France in the seventeenth century, was a slender tube that was coiled into a large hoop that could easily be slung over a huntsman's shoulder. The tube was only about 7 feet long and was much more cylindrical than a modern horn. The eighteenth-century cor de chasse, the typical instrument in the orchestra of Bach's and Handel's time, was twice as long and coiled into a double hoop. This instrument had no valves and was originally played with the bell pointing up and out. It could therefore play only the notes of a single harmonic series. This severely limited the parts a single instrument could play; a horn that could play a harmonic series on an E flat fundamental, for example, could play some, but not all, of the notes in the key of E flat, could play even fewer notes in keys closely related to E flat, and could play no notes at all in keys not related to E flat.
This meant that a horn player who wanted to be able to play in more than one key would need several different horns, would need time to switch from one horn to another whenever the music changed keys, and would still not be able to play every note in the key. For centuries, the history of the horn was a history of the search for solutions to these limitations.
One solution to this problem was to add a second set of players. One pair of horns could play in one key; the other in the other key. The setup of the modern orchestra often still reflects this early solution, with four horns playing in two pairs, and the third horn part almost acting like another first horn.
A second solution was to change the position of the horn so that the bell rested on the player's leg, and the right hand could be placed inside the bell. The player could then use the hand in two different ways, partially blocking the air flow, or almost completely stopping the air with the hand. Partially blocking the air lowered the pitch by about a half step, but the full stop basically shortened the playing length of the instrument and thus raised the pitch by about a whole step. The timbre of half-stopped and stopped notes are very different from each other and also very different from the sound of "open" notes. They can sound very jarring to modern ears. But hand-horn technique, invented by a Dresden horn player named Hampl around 1770, allowed the entire chromatic scale to be played on a single instrument without pause. This was so useful that hand-horn became widely accepted in spite of its timbre idiosyncrasies. In fact, it continued to be expected and used for decades after it was no longer really necessary.
Finally, there were many mechanical solutions. A very popular early solution involved adding extra lengths of tubing to the instrument to change its key. There were different ways to add the extra tubing: crooks could be fitted into sockets in the hoop, couplers could be added in between the mouthpiece and the instrument. Now a single horn player could play in many different keys with only one horn and a bag of crooks or couplers. He still needed time to change the crooks on his instrument when the music changed keys, but not as much time as before. To simplify things for the horn player, the composer would indicate which crook was needed (a movement might be labelled "for horn in A") and transpose the part for that instrument. This made the music easy to read - the first harmonic always looked like a C, the third like a G, and so on - easy for the horn player of that time, whose instrument was transposing the notes for him, but harder for a modern horn player trying to read older music, who may have to transpose the A part to her accustomed horn in F.
Of course, the ideal horn could switch crooks nearly instantaneously, and many new horns were invented to provide this solution. Some more successful than others. The omnitonic horn attached all crooks to the instrument, with a device to switch from one tube to another. This made it very easy and fast to change crooks, but hand horn technique was still needed to be able to play any note in the key.
The invention that really freed the horn to play the full chromatic scale easily was the valve. A valve can open and close almost instantly, redirecting the air through an extra crook in the middle of the instrument. It's really not clear who first invented a valved horn and when, but n 1818 a valve horn with two piston valves was patented; in the 1830's a third piston was added. Although most other modern brass still use piston valves, the horn switched to rotary valves, apparently invented by Joseph Riedl of Vienna around 1832. The modern horn uses three rotary valves, which lower its natural (F) harmonic series by a half step, a whole step, and one and a half steps, giving the horn a quick and easy chromatic scale. (For more on why three valves is enough for a brass instrument, see The Harmonic Series.)
Most modern horns are also double horns, that is, two horns in one. When instrument makers and players were settling on which of the many instruments (Horn in D? In E flat?) to use for the modern valved horn, the F horn was originally chosen as having a particularly full, moderate, and pleasing sound. But it is difficult to play high notes accurately on the F horn, so a second set of crooks, for the smaller, higher B flat horn, was added. A fourth valve, or trigger opens the shorter set of crooks, switching the instrument from the F "side" to the B flat "side" to play high notes.