We know the disk is an extension of the memory when the computer goes into insufficient memory, it will page out some pages to the disk, but do you know where it usually stored? In the Windows world, it will be dumped to the pagefile.sys which located to your default root path of your C drive, in the Linux world, there is a special partition named swap, it will send pages out there.
Why we need to page out inactive or unused pages because we don’t have enough memory to load all the application to the memory and it is unrealistic and doesn’t make sense to purchase the same size memory like your hard disk. In OS spec, there is a virtual memory (virtual space) and page table to make application itself believe all the data is loaded into the memory, actually it is not. When pages were not stored in the memory, the OS will send out interruptions of page fault to load the data from hard disk to memory, same time if the computer in memory low status it will replace some of the inactive pages to the swap space.