A page file acts like a physical extension of RAM and is used to offload excess or idle data from the memory to the hard disk. It's necessary because if the main system RAM is overloaded and no page space is available, a program could crash and potentially lose data.