A good question.
Roadbed is a system with many components functioning as one and for various reasons.
The ballast holds the ties in place when there is no weight on them. And it also serves to permit drainage.
The ties serve as a base for the rail, spreading out the load and maintaining the gage.
Then comes the tie plates. The base of the rail fits into them and these are what is spiked down with the spike heads over the bottom sides of the rail, inside and out securing everything.
Next come the rail anchors or known as "creepers" where I worked. Basically shaped like the letter 'J' these are hammered onto the base of the rail and grip the rail, with them placed on each side of each tie. This keeps the rail from moving front to rear or rear to front horizontally. With out them the rail could be pushed along for a very short distance before the train scatters all over hell and back. A locomotive in heavy dynamic brake can do just that.
Then comes the rail that rides on all the above. They are an "I" beam of sorts. There is the wide base, the thin 'web' topped off with the 'ball.'
But of course there is more to it than that.
The next time you see a train pass in front of you, at a SAFE distance (a 50 foot minimum) or in your car when stopped by a passing train look what happens to the rail as each set of car trucks passes over. You will see the rail take a major nose dive of a couple of inches. This is by design. The roadbed in a way is fluid. This helps dissipate the huge forces at play where wheel meets rail. Were it not so, the train would derail, as the car's running gear would have to absorb all the loads at play, horizontally, laterally and perpendicularly and they are very extreme. Most average loaded cars tip the scale at 138 tons or more each.
All is especially true when dealing with Continuous Welded Rail (CWR) also known as 'ribbon trail.' When laying or replacing the rail, it must be heated in the field to the proper temperature. People often ask what they are seeing when they see fire along the base of the rail while passing on the highway. It is called 'burning a rope.' And that is exactly what it is. A hemp rope soaked in kerosene. The temperature is critical and varies from place to place according to predominant weather conditions.
But that doesn't cure all the problems.
In extremely cold weather, 10 to 15 degrees F or less, almost every night some ribbon rail pulls apart because the temperature extreme causes them to contract farther than their ability to do so and they literally pull apart. Of course this turns any related signals red.
Conversely, in extreme heat the rail can expand farther than their ability to do so. That is when you get a "sun kink." Usually in curvature, the rail will actually force the ties out of the ballast on the outside of the curve. If too radical, a derailment is the usual result. For that reason, in heat extremes in the summer the maximum authorized speed of trains is usually reduced in anticipation.
Speed is also restricted when the roadbed has been disturbed, like replacing ballast or adding new ties. Usually a 10mph restriction, until the trackage has 'consolidated.' Used this way, this is an engineering term meaning that as trains pass for several days this allows everything to settle and gel and become that solid but flexible roadbed system.
Most ties are made of wood, but in some areas concrete ties are used. The latter is usually found in extreme curvature and on heavy grade. Concrete ties are usually found on high speed track as well. In this instance we find rubber tie plates that are screwed down with the rail.
But there is a trade off here. A car can have a derailed wheel or a set of trucks and can cut the wooden ties for some distance, and this allows for more time for someone to notice and get the train stopped before a derailment happens. That has happened to me more than once.
On the other hand, when a derailed wheel or truck hits a concrete tie, the tie basically explodes and the pile up happens right then and there. No chance to be discovered beforehand.
Keep in mind a train can derail at any time, at any place or at any speed regardless of the quality of the roadbed. That is where the 50 foot safety margin comes in to play. This also applies when stopped a grade crossing. Give yourself some room or you may wind up with a 138 ton car load of lumber in your lap.
Be smart to be a survivor.