The purpose of the caboose is to allow the train to be supervised from the rear and ensure that cars from the train cannot separate without the crew's knowledge. Should the train part in the middle, the crew on the caboose can apply the brakes on the trailing portion and signal for assistance. This allows the locomotive crew to concentrate on events ahead.
The caboose is also used to monitor the cars and load making up the train, making sure there are no problems - load shifting dangerously, overheading axleboxes on the cars (hot boxes) that could cause fire, and suchlike. A caboose is also fitted with red lights to enable the rear of the train to be seen at night.
Until the 1980s it was legally mandated in the United States and Canada that all freight trains had to have a caboose. Technology eventually advanced such that a caboose was unnecessary; improved bearings and lineside detectors to detect hot boxes, better designed cars to avoid problems with the load, and electronic end-of-train devices that could be attached to the rear of the train to detect the train braking apart and allowing the brakes to be applied from the rear by remote control. These days, the caboose is rare, being used only on maintenance trains and the like.
Similar situations prevailed in other parts of the world, so that these railroad cars -- under whatever name is used -- are almost obsolete.