The huge weight of the train on the steel rails needs to be spread out over a large area to reduce the pressure. The rails are fixed to concrete sleepers which rest on ballast (the small rocks). This is a firm foundation upon which to rest the sleepers.
Called 'ballast', it provides a foundation, and drainage, for the sleepers, (US = ties). If the sleepers were laid on bare earth, the trains passing over them would make wet earth squishy, and end up making the track sink into the ground.
To keep the track in place. It has proven to be the most suitable material, and though one small rock may not weigh much, the total mass for the area (or volume) covered is much heavier than the weight of any train, plus track, over the same area (and that includes the momentum of the train travelling at speed). I believe the correct term, for this purpose, is ballast.