Riding roller coasters is one of the world’s most popular amusement pastimes. People will sometimes wait for hours to ride the newest thrill ride or an old classic.

There are many reasons that people ride and love roller coasters: they enjoy the speed, the seeming danger, and like a little kid riding a wagon a bit too fast on a curved side-walk, they like being scared.

Oddly enough, none of these things were the primary reason for the invention of the roller-coaster. The thing that motivated the inventor of the roller coaster in the late 1800s was immorality.

Believing that America was both creating and rushing into a den of iniquity, LaMarcus Adna Thompson was on the lookout for a past-time that would draw Americans away from the taverns, gambling and dancing halls, and brothels that were becoming increasingly popular as the nation grew more and more prosperous after the Civil War.

Born in Ohio and later moving to Elkhart, Indiana, Thompson had invented a device to manufacture seamless ladies stockings and other hosiery. This business and his patent made Thompson a rich man. He retired early, due to poor health, earning money from his patent.

Thompson was an intensely religious man, and like many Americans of the time, he was concerned that the increasingly wealthy and urban culture developing in the country was a decidedly bad influence. He wanted to do something about it.

On a pleasure trip to the relaxing hills of Pennsylvania, Thompson was inspired by something very different than women’s hosiery.

At the oddly named town of Mauch Chunk in the eastern part of the state, Thompson came across people riding an old mining railway – for fun.

The Mauch Chunk railway had been constructed to transport coal to the nearby docks on the Lehigh River and then onto the steel mills of Bethlehem.

The railway had been converted to a vacation experience when the coal mines of the area began to fade. In the early 1800s the railway was nine miles long and mules were used to pull coal carts up nearby Mt. Pisgah.

Later in the 19th century, the railway was expanded to some eighteen miles, and the mules were replaced with a steam engine. However, most of the length of the track was a gravity-powered switchback.

The cars rolled down the track at speeds that sometimes far exceeded the speed of a running horse or a train – remember, these were the days before cars and planes: nothing man-made moved that fast.

For the people visiting the hills around Mauch Chunk, the railway was a thrill. Some people called it “harrowing,” because at the end there was a 600-plus foot “drop.” That drop was more like a slope, but there was nothing comparable at the time. By the time LaMarcus Thompson visited, tourists paid one dollar (not cheap for the time) for a ride on the railway, which took 80 minutes to complete.

This gave Thompson his idea. He drew up plans for a smaller version of the switchback railway he had seen.

It would include a couple of features that he had seen in Pennsylvania, like the “train” cars themselves, and a ratchet system to prevent the trains from rolling backward. He designed the now familiar wooden frame structure and patented his idea.

The first Thompson “roller coaster” was built in the spring of 1884, at Coney Island, New York. Established as a resort area in the first part of the 1800s, by the time the Civil War ended, Coney Island had theaters, a racetrack, restaurants, and to the delight of many who thought differently from Thompson, many taverns and bordellos.

While not legal, these “Houses of Pleasure” were mostly tolerated with a knowing wink, as long as things were kept properly discreet and orderly.

Thompson chose Coney Island for precisely this reason.

His “Switchback Railway” would keep people out in the fresh air, out of the taverns and brothels, and keep families together.

The price of a ticket was a nickel. There is some debate about the top speed, but it was less than ten miles per hour. Again, other than a horse (which few people in Coney Island had ever ridden) and a closed-in train, ten miles an hour was fast.

There were no cars, no planes, and few people at the time owned bicycles. The elevation of Thompson’s original ride was fifty feet and it was six hundred feet long.

Starting at the top, the cars rode down the length of the track, which included a couple of small dips.

At the other end, gravity carried the riders up another hill, and they then returned to their starting point. Two train cars would be operating at the same time.

Within three weeks, Thompson was making some six hundred dollars a day — the equivalent of fifteen-thousand a day today! Within a short time, Thompson was making improvements and patented them. Soon others were developing their own switchback railways.

Many of them increased the speed, which made them popular. Thompson’s amusements, which he began to build across the country, did gradually increase speed as well, but Thompson focused on adding novelties: tunnels, lights, fake mountains, “scenery” next to the track, etc.

The popular Space Mountain ride at Disney World with its dark tunnels and flashing lights is a direct descendant of Thompson’s first rides.

The term “roller coaster” came into vogue in the late 1880s, most likely taken from the name of a type of winter ride which featured a toboggan on rollers which was pulled to the top of a snowy hill, much like Thompson’s railway.

In actual fact, Thompson was not the inventor of the roller coaster. Similar gravity rides had existed for a short time in France before Thompson’s ride, but never quite took and soon were a thing of the past.

Read another story from us: The Sneaky Ways America First Lured Innovative Thinkers and Industries to its Shores

By the time he died at the age of 71 in 1919, Thompson was a very rich man. Millions of people were riding his rides and having the time of their lives – well, almost…Thompson’s rides never quite replaced bars and bordellos.