Virtual memory is an old concept. Before computers had cache, they had virtual memory. For a long time, virtual memory only appeared on mainframes. Personal computers in the 1980s did not use virtual memory. In fact, many good ideas that were in common use in the UNIX operating systems didn’t appear until the mid 1990s in personal computer operating systems (pre-emptive multitasking and virtual memory).
Initially, virtual memory meant the idea of using disk to extend RAM. Programs wouldn’t have to care whether the memory was “real” memory (i.e., RAM) or disk. The operating system and hardware would figure that out.
Later on, virtual memory was used as a means of memory protection. Every program uses a range of addressed called the address space.
The assumption of operating systems developers is that any user program can not be trusted. User programs will try to destroy themselves, other user programs, and the operating system itself. That seems like such a negative view, however, it’s how operating systems are designed. It’s not necessary that programs have to be deliberately malicious. Programs can be accidentally malicious (modify the data of a pointer pointing to garbage memory).
Virtual memory can help there too. It can help prevent programs from interfering with other programs.
Occasionally, you want programs to cooperate, and share memory. Virtual memory can also help in that respect.