The term you’re looking for is [“Ballast”](https://www.google.com/amp/s/slate.com/human-interest/2013/09/why-are-there-crushed-stones-alongside-rail-tracks.amp) which is a type of [“gravel”](https://en.m.wikipedia.org/wiki/Gravel).
To answer your question: the rails shift slightly, and expand/contract as the heat and cool throughout the day. Furthermore, the sit unburdened 99% of the time, but occasionally have to support weights of 1,000,000lbs or more. The layer of ballast keeps the track from moving without firmly securing it in place (which would snap the rail from the nontrivial expansion/contraction cycle).
The first link I posted has a solid explanation (which I’m paraphrasing here)
Latest Answers