Helmets were, of course, first invented as part of armor. The word "helmet" means "small helm" and meant a helmet that only covered part of the head. The modern hard hat for construction use was invented in 1919 for miners - before that, leather helmets were sometimes worn.
As hunting with hounds at speed became a more popular sport in the 19th century, the hunt cap became popular - this was a lightweight hard hat that lacked a chin strap and provided only a small amount of protection. Chin straps started to become popular in the early twentieth century.
The modern riding helmet, though, has its origins in racing. In 1941, accident insurance was introduced for jockeys - which meant head injuries started being tracked. The first payout went to the family of an 18-year-old apprentice, Joe Giangaspro, who died of a head injury after a race at Hialeah.
In the 1950s the Jockeys' Guild, which governed the insurance, put effort into developing a proper safety helmet for jockeys. (This is also when goggles became mandatory for jockeys). In 1956, the "Caliente" helmet was introduced in the US. Proper safety helmets spread from racing into other equestrian fields. In the 1990s, helmet laws began to spread through the western world - often helmets being mandatory for youth under 14 or when riding on the road. Many western and dressage riders, however, still refuse to wear helmets.