Forget the OS. It is usually programs, scripts, or you, who run programs. All these preferably want to know what did happen. The return value can be tested, and based on it choose the next thing to do.
A simple one-liner on suitable shell. It will execute program "foo". If that ends with "success", then the "bar" will run. If still successful, the "gaz" will run last. If either of the first returns a non-success, the rest are not run.
If you know the error codes returned by a program, you can (with if-else) do different things depending on why the program did quit.
A batch execution system can keep statistics on "jobs" and point out if the jobs fail. Nobody wants to give CPU-hours from multi-million clusters to computing jobs that do not succeed.
Have you ever compiled a C++ program? Did you use an IDE? Compilation invokes preprocessor, compiler, and linker. All must succeed. The IDE has to know the outcome so that it can show you something. Return values are really useful.