Train engines were too crowded for conductors to work comfortably, so the caboose was created to function as an additional workspace, living quarters, and a crew lookout post.
Until the 1980s, the caboose was a mandated part of trains in the United States and Canada. As a place to survey the line for damage, it was an essential safety feature.
However, the invention and installation of monitoring systems on the side of train tracks and at the end-of-train device (ETD) made cabooses obsolete as a piece of railway safety.
As for a resting place for the crew, rail companies started paying for motel rooms by the '80s, and conductors needed less space when their paperwork went to computers.