Virtual memory allows programs to access memory addresses that do not physically exist, expanding the available address space. When a program accesses a virtual address, the memory management unit translates it to a real physical address. If the requested page is not in memory, it is swapped in from secondary storage. This allows programs to behave as if they have more memory than is physically installed, improving efficiency and allowing more programs to run simultaneously.