Lot of information is already out there if you just search, but still, I'll try to compile basic concepts to explain what an RTOS is.
Operating System vs Real Time Operating System
First thing first, a Real Time Operating System guarantees timely response to any event as against an Operating System. (It is hard to explain to millennial, but) Do you remember times when pointer on your Desktop PC used to stop responding to mouse movements and then you'd press NumLock button on keyboard to find out if PC has hanged? Well, that's the difference between Real Time Operating System and Operating System.
Hard Real Time OS vs Soft Real Time OS
Within RTOS, there are 2 different branches - Hard vs Soft RTOS. Hard RTOS guarantees immediate response to an event. Soft RTOS, on the other hand, guarantees response within realistically acceptable time.
That means, if an Operating System guarantees response to an event within well defined, stipulated, realistic and predictable time period, every single time, then it can be termed as Soft Real Time Operating System. For example, if switch state change is responded
within 1 millisecond in worst case, it's Soft Real Time.
Whereas, if an Operating System guarantees response to an even at exact same time from occurrence of event, it is a Hard Real Time Operating System. For example, if switch state change is responded
exactly at 100 microseconds from change, every single time, then it's a Hard Real Time.
Need for an Operating System
In a simpler system, one may just monitor the inputs, to drive the outputs, in one-by-one fashion. Let's take example of manual AC in a car. You read state of inputs like AC on/off switch, temperature knob, fan speed, etc. one-by-one. Then do some calculations to decide the on/off state of compressor and heater, fan motor speed and heated/cooled air mixture ratio etc. Then output the calculated values to drive the mechanical components so that heated/cooled air can be blown.
Now, if you want to move to automatic temperature control, the scope has increased. Now, you don't just have to read inputs to drive outputs, but run some closed loop control of:
- cabin temperature - which is function of all the below variables
- heater temperature to get warm air for optimum energy consumption and to make above control loop 1 easy
- fan speed to change rate of cooling/heating
- compressor on/off control to maintain optimum cooling, again, for optimum energy consumption and to make above control loop 1 easy
- etc.
Now, considering that all these closed loop controls have to run in parallel, it becomes difficult to build a software using one-by-one approach. This is where an Operating System comes in. An OS runs multiple loops (typically termed tasks) concurrently. While running these tasks, it makes sure that they do not interfere with each other. Advantage that the tasks have is, they never have to worry about the other running tasks in the system, they just mind their own business and be done.
Need for Real Time Operating System
Above example shows need for an Operating System, but it does not demand Real Time responsiveness. Even if the temperature changes over few hundred milliseconds, no-one will complain - or rather even notice.
So, let's take example of ABS. ABS needs to monitor the applied brake pressure, and push the calipers proportionally. Then read speed of each wheel individually and compare the rate of speed drop against brake command and against realistic deceleration under load. Based on this rate of deceleration, do some math to decide if brake caliper pressure is to be maintained or dropped or raised. Continue monitoring any brake pedal position change from the operator all the while, to make sure primary command is always obeyed, during ABS correction.
This operation cannot rely on an Operating System that
does not guarantee predictable and realistic, timely response. The required corrections demand instantaneous response to all the inputs (break pressure, speed change, etc.). Hence the need for an RTOS.
Need for Hard Real Time Operating System
ABS demands timely response, but, it can still be within few milliseconds range. Fact is that, the braking system itself has sluggish response time which runs into some milliseconds. As long as the RTOS responds within that period of time, the ABS runs smoothly.
So let's take example of Airbag. For correct operation of an Airbag, the system needs to read arrays of impact sensors. It needs to detect the intensity of the impact. And it needs to be absolutely sure of the severity of an impact. The system must not deploy airbag in a car running at 100 kmph, just because a pebble hit one of the sensors. Such false airbag deployment would be a cause for an accident.
Hence, all these complex calculations need to be complete within few milliseconds from an impact and the system needs to run multiple iterations to be absolutely sure of actual hazard. Once deploy signal is sent, there is no turning back. You don't need me to tell you that this system would require a Hard Real Time Operating System for reliable operation.
Note:
Although I have thoughtfully selected the examples, there is no hard-and-fast rule. Meaning, Auto AC can still be run without an Operating System. Off-course it's performance will be lame. On top of that, if you avoid using Operating System, task synchronization becomes a headache. Then the designer/developer of the system has to spend major time in debugging/testing/understanding system from software point of view, rather than functional point of view.
An Operating System takes a lot of load away from the application developer, so that (s)he can focus on functionality rather than software engineering.
Well, someone has to take the effort to engineer software - so then it's responsibility of the one who creates an OS (yeah, that's me...

)
Similarly, Auto AC can be built on Hard RTOS, but it's an overkill. It's just too much to ask.