a railroad car with accommodations for the train crew,
typically attached to the end of the train.

New York Central System #17965 - Ypsilanti, Michigan
This caboose was built for the New York Central Railroad and was retired between the 1980's and 1990's. Today, it serves as a local landmark here in the historical "Depot Town" here in Ypsilanti, MI.
Nowadays, the caboose car itself is rarely used by railroads in North America, but before the 1980s, almost every train ended in a caboose which was usually painted red. There were occasions that the caboose would be painted in colors to match the engine at the front of the train.
The purpose of the caboose was to provide a rolling office for the train's conductor and the brakemen. The conductor was the railroad official who was responsible for the train from front to back. Essentially, he was the train's "captain" and it was his job to ensure that the train arrived at its destination safely, and with all the cargo that had been loaded, delivered properly and intact. It was also his responsibility to ensure that the train was loaded with enough fuel to make its destination, and that it was "rail worthy" and safe. In order to do all this, it became customary by the 1850s to include a small box car on the end of the train where the conductor could do his work, and also serve as the conductor's quarters.
It wasn't until 1898 when one of the handful of designs that the caboose would take would be seen by the public. The caboose we see here is a design that included the distinctive "cupola" and rises a few feet above the rest of the car, as well as the rest of the train. The purpose of this high seat surrounded by windows was to allow the conductor to see what was going on all the way up the train to the locomotive. At that time, applying the brakes had to be done manually by turning a wheel located on each car. The brakemen used ladders to climb to the top of the train, and would walk along the the roof of the cars in order to access the brake wheel on each of the cars.
From his cupola, the conductor could see and direct this activity as well as any others that required travel between the front and rear of the train.

Shown above is caboose #205, a C-30-3 class wooden caboose which was built in 1930
As a rolling office and living quarters, the caboose was equipped with everything someone living on a mobile platform would need: a desk, restroom, water supply, stove, heater, bed and even an icebox. This office space would also include storage for all the supplies someone would need including oil cans, red signal flags (in case of emergency), lanterns, and also extra lantern fuel. It was the rolling headquarters for the train.
Although this system worked for over 100 years, it did have a few issues and drawbacks. Before the invention and advancement of electronic communication, information between the conductor and the engineer in the locomotive was accomplished by hand-signals and other forms of visual communication.
The conductor would usually have a caboose assigned to him, which was not always the most cost-effective way of doing business for the railroads either, as this was many times an expensive task to move the caboose along with the conductor, from train-to-train depending on the assignment.
Over the decades, the railroads stuck with the caboose because, despite the expense, it worked.

"Blueprint" plans for a typical caboose with cupola
As a rolling office and living quarters, the caboose was equipped with everything someone living on a mobile platform would need: a desk, restroom, water supply, stove, heater, bed and even an icebox. This office space would also include storage for all the supplies someone would need including oil cans, red signal flags (in case of emergency), lanterns, and also extra lantern fuel. It was the rolling headquarters for the train.
Although this system worked for over 100 years, it did have a few issues and drawbacks.
Before the invention and advancement of electronic communication, information between the conductor and the engineer in the locomotive was accomplished by hand-signals and other forms of visual communication.
Another drawback was that the conductor would usually have a caboose assigned to him, which was good for the conductor, but was not always the most cost-effective way of doing business for the railroads. This was many times an expensive task to move the caboose along with the conductor, from train-to-train depending on the assignment.
Over the decades, the railroads stuck with the caboose because, well, despite the expense and problems, it worked.
Despite these processes that had worked for years, things began to change in the 1960's. Computers and technology were being developed and began to be more pervasive on the railroads. Technologies were developed where a crew of dozens of brakemen that had once worked on a train were no longer necessary, as air brakes could stop a train without them.
The locomotives that had once been steam-driven and coal-fired and had required several people to keep that train moving, would be replaced by engines that were diesel-electric. The job of being an engineer shifted from stoking the boiler to operating an increasingly computerized cockpit with a much smaller crew to keep things moving.

Typical controls of a modern-day locomotive
Communication across the train would change from hand-signals and later 2-way radios to electronic sensors and computers. The caboose's function began to be eliminated by the technology that was advancing quickly.
Some of these technological advancements included some redesigns of the railcars as well as train-to-track sensors which would help to avoid problems with the loads.
The railroads also claimed a caboose was also a dangerous place, as sometimes "wild movement" (including slack/space between the couplings) of the train itself due to unforseen stopping or side-to-side motion along the rail route, could hurl the crew from their places and even dislodge weighty equipment.
Because of the technology, the costs, as well as safety concerns, the railroads proposed an alternative to the caboose. This proposal included a device, called a ETD (End-of Train Device) or FRED (Flashing Rear End Device) to be attached to the rear of the train that could detect many things that had previously been monitored by some of the crew. The ETD/FRED could detect the train's air brake pressure, detect movement of the train upon start-up, as well as communicate other diagnostic information such as "slack" to give the Engineer the details needed to apply the proper amount of power and other information. The devices would also have blinking red lights to warn following trains that another train is ahead or stopped on the track for any reason.

An ETD on a container train in 2005
With these advancements and addition of a small device, instead of a large added railcar, the Conductor could move up to the front of the train with the Engineer, thereby rendering the caboose almost obsolete.
The laws that were in-place since the railroad's beginning had required the railroads add a caboose and full crew for safety. The laws had not been able to predict the advances that would come and it would take a change in these laws to allow for the elimination of this large rolling-office that had been part of every train for over a hundred-plus years.
A 1982 Presidential Emergency Board convened under the Railway Labor Act directed United States railroads to begin eliminating caboose cars where possible to do so. A legal exception was the state of Virginia, which had a 1911 law mandating cabooses on the ends of trains, until the law's final repeal in 1988. With this exception aside, year by year, cabooses began to retired and fade away.

Because there is no caboose, the employee must stand
on the last car of this Union Pacific train going in
reverse, to make sure the track is clear — something
the ETD doesn't currently do.
Today, with a few exceptions where either due to logistics on long-reverse movements, or situations with Hazardous Materials, a FRED is attached to the end of every train. This one small device is now doing the job that a hundred years ago took a crew of dozens to do.
Nowadays, very few cabooses remain in operation although they are still used for some local trains where it is convenient to have a brakeman at the end of the train to operate switches on long reverse movements. They are also used on trains carrying hazardous materials, or even sometimes used around railyards for storage purposes or railway maintenance including times where survey crews inspect remote rail lines that have been damaged by natural disasters.

The interior of an Indiana Harbor Belt Railroad caboose in 1943
There are also times when the cabooses are called-upon for historical tours or special events, but for the most part this long-loved piece of the railroad is found mainly in the history books and memories of rail fans everywhere.