Early jet engines had only one set of compressor disks which were sitting on the same shaft and spinning at the same speed. More modern designs use two or even three concentric spools, each spinning at its own speed. All spools have several compressor discs at the forward and one or a few turbine discs at the rear end, and allowing them to run at different speeds allows each compressor-turbine combination to run more efficiently. Note that all compressor components increase pressure downstream.
Gas turbines must be able to run efficiently not only at full thrust, but also at intermediate thrust settings. Especially in cases where the airplane is not fully loaded, airlines prefer to reduce thrust somewhat, because this stresses the engine less. Enabling different speeds allows to adapt the engine better to the operating conditions. Adding a spool adds complexity and introduces new failure modes, but the difference in speeds between the components makes obvious how much benefit they bring. In case of the GE-90, the low pressure spool runs at 2261.5 RPM when N1 is 100%, and the high pressure spool runs more than four times faster at 9332 RPM when N2 is 100%.
Rolls-Royce's success in the engine market is largely due to its ability to tailor its Trent engine to the many variants of aircraft which are sold by Boeing and Airbus. This tailoring is done by adapting the low speed components while leaving the core identical between models. By having three components to tinker with while its competitors General Electric and Pratt & Whitney have only two, Rolls-Royce has an advantage in the business of offering tailor-made engines.
Another reason for having two independent rotating assemblies can be found on vertical take-off jets: By spinning the low- and the high-pressure components in different directions, their gyro forces can be greatly reduced. While this is not relevant to regular airplanes, hovering a vertical take-off jet is much simpler when its engine does not add a pitch motion to every yawing motion and vice versa.