An operating system (often abbreviated to OS) is a program which uses only the capabilities provided directly by a computer's hardware, and gives users a more functionality-rich environment in which to do their work.
The functionality of operating systems has expanded over time, as the complexity of computing systems, and the uses to which they were put, expanded.
The meaning of the term has also changed over time; originally, it meant only the core OS, what we now call the kernel; it has since expanded to include many of the utilities (such as the command processor) which go together with the OS to make up the environment most users see.
Among the first things they did was to hide the low-level details of the devices attached to the system, so that users could use them by specifying higher-level operations (e.g. 'print this string', instead of having to directly massage device registers).
Initially, computers on did one thing at a time, but the machines of that period (essentially all mainframes, in modern terminology) were so very expensive that it was crucial to keep them fully utulized at all times. Therefore, batch operating systems evolved, to handle a queue of 'jobs', so that the computer could proceed to the next one as soon as the prior one completed.
Operating systems then began to manage the the resources of the computer (CPU, main memory and disk secondary storage). So, for example, operating systems provided file systems for users to store their data in.
(Which led to a Dave Clark aphorism that 'the function of an operating system is to provide multiple names for things in the system, so that it can busy itself keeping track of the relationships between the names' - as in this case, where block numbers and file names are involved.)
The 'batch' method of interacting with computers (one handed in one's 'job', waited for it to be run, and then got the output - if any! - back) was efficient for computers, but not for people. In the early 1960's, another method of interacting with computers, time-sharing, developed, in which a single computer could be shared among many users simultaneously, through the use of pre-emptive multi-tasking.
This required the operating system to ensure that one user could not interfere with another user, so protection of users (and their data, stored on disk) from each other became another function of the operating system (although to do this propely generally required support from the hardware of the system).
At about the same time, virtual memory (which allowed a user to perform large computations on computers with a limited amount of memory, without having to concern themselves with moving data back and forth from disk, to the limited amount of main memory actually available) appeared, and (once the hardware could do it), managing virtual memory became another standard OS responsibility.
As computers became cheaper, with the development of minicomputers, and then microcomputers, it became feasible to have computers interact with other equipment, in order to record data, or control things. This lead to the development of real-time systems, which had their own needs.
The developmen of personal computers recapitulated almost this entire development sequence; early PC OS'd provided only distance from the details of the hardware, but multi-tasking soon followed, and then virtual memory.