Compressors are unstable machines. If the mass flow is too low the aerofoils can stall, this creates a phenomenon called rotating stall. Stall cells form and rotate inside the machine, performance is compromised, pressure rise drops and efficiency falls. If the pressure rise is high there is a risk that this process causes surge of the whole engine: this can result in flames comming out tof the fan. If this happens the engine has to be shut down: frightening if you are in flight! The bleed valves avoid these dire consequences by blowing air out and increasing the air flow through the compressor. The performance effect is very negative, SFC increases and a lot of noise is generated, but the engine still can run which is the whole idea.
Besides, Martin clarification you may distinct between two cases where the bleed-off valve functions are critical.
During start up condition:
Among the most critical parameters during engine starting are the compressor stall margin, and the required torque. In such cases, the conditions of low flow, and low speed off-design are fulfilled. The positive OR negative angle of attacks MAY BE revealed in startup due to design incapability to satisfy optimum angle of attack for both front and rear stages. As surge margin is the difference between the flow of both equilibrium running line and the surge line, bleed-off valve is used to improve the surge margin by accommodating high flow at compressor front stages and low swallowing capacity of the rear stages.
During shutdown and part load conditions:
When the engine speed is reduced, the flow in the rear stages of an axial compressor is accelerated due to the density decrease and thus may cause choking of the rear blade passages. Increasing the axial velocity decreases the angle of attack and the flow separates from the pressure side of the blade; this is known as negative stall surge. However, for low axial inlet velocities, the angle of attack is increased and the flow separates on the suction side of the blade. Opening the bleed valve moves the equilibrium running line down and away from the surge line on the compressor characteristic map, as it permits high mass flow at the front stages, while less flow is passed through the rear stages.
Citing Saravanamuttoo: “The incidence could be maintained at the design value by increasing the speed of the last stage and decreasing the speed of the first stage. These conflicting requirements can be met by splitting the compressor into two or more sections, each being driven by a separate turbine.” So yes two spool configurations is a solution to avoid stability issues during low power operation, as is compressor stators variable geometry (VIGVs and VSVs) and Bleed Off Valves. There are engines that utilize only one method for ensuring stability (e.g. RR Olympus: two spool three shaft engine, no BOV no variable geometry, GE LM2500: twin shaft engine only variable geometry stators and VIGVs), there are engines that utilize two methods (e.g. RR Tyne: two spool three shaft engine and an intercompressor BOV) and engines that utilize three methods (e.g. LM6000, which is a two spool engine with intercompressor VBV and HPC VSVs). The decision has to do with several parameters, since applying only one method may not give sufficient Surge Margin during transients or may result to significant part load performance penalty; additionally for really high OPRs a single shaft solution is not viable due to torque limitations. As mentioned in the insightful replies BOV is a bad solution in terms of overall engine performance, but it is a simple solution. I would recommend reading “Gas Turbine Theory” by Saravanamuttoo (Ch. 5: Axial Flow Compressor sec. 5.12) Walsh and Fletcher “Gas Turbine Performance” (Ch. 5: Gas Turbine Engine Components, sec. 5.2.7) and Rolls-Royce “The Jet Engine” (Ch. 3, sec. Airflow control”) as an introduction to the subject. I hope this helps.
Another point is that bleed air is also used for cabin air pressurization in aircraft. See the corresponding article (and especially the articles in the sources section):