In simple terms, swap is used to extend your RAM. But that’s not the end of the story!
Currently in use programs, and files, are being kept in the RAM (random access memory). But what happends if your RAM runs out? Where do files go? If your system in on the brink of crashing due to no available memory, the out of memory killer will kill a process which uses to much RAM. And this is when swap comes into play.
Swap will bascially extend the amount of RAM you have. But because we can’t Download more RAM we have to use the disk. So the swap is not as fast as your memory, but will make sure we can continue operations.
If you want to learn, how to create your Linux Swap File, look no further, and look here.