The role of the subgrade in railways is similar to that of a building foundation. The applied loads are transferred by the deflection of the rail to the ballast bed and then passed on via the subgrade to the subsoil. The effects of a subsoil that cannot carry much load are devastating. Back in the 19th century it was recognized that the proper drainage of water and the adequate dimensioning of the load-bearing capacity were key factors in the success of the railway system.
Earthworks facilitate the adaptation of the existing terrain to the track. 97% of the railways in Europe are on embankments, cuttings or structures. When building new lines attempts are made to use the earth obtained from cuttings on one site to construct an embankment on another site. The previous use of any old surplus bulk material for filling and insufficient consolidation can still be clearly seen even today on certain railway lines. 
Formation - formation protective layer (FPL)
The formation is a boundary layer between the ballasted track and the underlying subgrade or subsoil. That part of the track between subsoil and ballast track is called the subgrade, the properties of which were changed by engineering measures. The subgrade therefore includes not only frost protection and formation protection layers (FPL), but also structures and other geotechnical features (e.g. culverts, side ditches, etc.).
The subsoil is the last link in a chain of different components. This accepts the high loads of the railway infrastructure, distributes them and dissipates them. In the early days of railways attempts were made to use brushwood, compact layers, cement, sand, etc. to positively influence the properties of the subsoil and to increase its load bearing capacity. Also, today packing layers still cause serious delays in track work sites if they are not recognized at the planning stage and taken into account. In 1954 the Deutsche Bahn examined different methods of improving the subgrade, in particular the use of sand-gravel mixtures.
The soil is not only loaded just by the force effects, but is subject to numerous weather conditions. When the temperature falls below zero degrees in winter for a long period of time, it also affects the soil. The water contained in the soil begins to freeze and expands through the change of its physical state. In the case of non-cohesive soils there is no problem, because the water in the existing pore structure has enough space to expand. This is quite different to low- or medium-cohesive soil. Due to the potential thermal gradient the water moves against the force of gravity from deeper regions upwards and forms water inclusions in the area of the equipotential which may freeze at low temperatures. The increase in volume leads to frost heaves. In the dew period, the soil has not only the lowest modulus of elasticity of the year, but in winter if ice fills the cavity the forces that result can produce a sudden settling of the trackbed. Water that cannot drain away changes the carrying capacity, so that there is an enrichment of fine particles especially in the transition zone between ballast and subgrade.
The increase in the fine-grain component of the ballast bed leads to a reduction of the shear strength and subsequently to a decrease in the load carrying capacity of the system as a whole. On the other hand the soil dries out after long periods of hot weather. This can lead to track settlements due to the rise of the modulus of elasticity. 
In the last few years the dynamic usability became more important due to the increase in load and especially speed on lines laid on soft layers.
In addition to far-reaching measures the installation of sand-gravel mixtures in combination with geosynthetics has proved successful. Since long track intervals tie up a lot of capital, attempts are made to avoid them by the use of multi-layered bearing-layer superstructure.
Problems in the subgrade are often only discovered at a late stage. If muddy places appear on the surface the effects on the complete system are normally so far advanced that it is necessary to replace all components. Even though formation rehabilitation is significantly more expensive than conventional track renewal, it shows its positive effect when the complete life cycle cost of the track is considered. Poor subgrade-increases the maintenance and reduces the useful life of the railway track. Studies from different countries quantify this effect as annual maintenance costs of the track being two to four times higher. 
The problem is often limited to subsoil with too little load-bearing capacity. Experience shows, however, that any kind of inhomogeneities can result in different settlements in the track grid. Especially stiff subsoil increases the load on the intermediate ballasted track considerably. In this case, it is necessary, by the arrangement of the elastic elements in the superstructure (increase in the ballast bed thickness, etc.) to distribute the loads even further and to compensate for sudden loads.
You can find suitable specialist literature about the topic here:
The second edition of Railway Ground Engineering has been completely reworked and extended. It provides comprehensive information on the essential relationships and dependencies between superstructure, substructure and subsoil subjected to the effects of the rail System.
This manual is intended to be a practical reference book for everyone involved in the planning, design and construction of earthworks and other geotechnical structures, as well as a manual for low track maintenance . With the comprehensive presentation of the new partial safety concept in geotechnics, it is also a valuable aid for students and teachers at universities and technical Colleges.
Best Practice in Track Maintenance, Vol 1 - Infrastructure Management
Infrastructure Management Volume 1 looks at aspects of infrastructure management with particular reference to the single European railway area. Based on best-practice examples from Central Europe, measures for the targeted retrofitting and improvement of the infrastructure maintenance of the existing network are presented. In many cases, infrastructure operators are faced with a generational change, which accelerates the process. Modern information and communication technology can simplify the comprehension and presentation of complex contexts. Modified approaches to asset management and life-cycle management enable implementation of the "transparent permanent way" or the "railway 4.0".
-  Fischer, R.; Göbel, C.; Lieberenz, K. et al.: Handbuch Erdbauwerke der Bahnen. Planung, Bemessung, Ausführung, Instandhaltung. Eurailpress in DVV Media Group, Hamburg, 2013.
-  Lieberenz, K.; Piereder, F.: Entwicklung von Schutzschichten mit Geokunststoffen. Eisenbahningenieur Kalender 2013, S. 252–270.
-  Hansmann, F.: Großmaschineneinsätze bei Untergründen mit geringer Tragfähigkeit, Sonderheft Geotechnik. Der Eisenbahningenieur 2016, Heft 6, S. 13–16