Swapping is used to increase the amount of free physical memory and improve performance.
When your computer starts up, a whole bunch of processes load. As these processes initialize, they allocate memory and modify its contents. Many of those processes will never, ever be used for the entire time the computer is running. Even for active processes, many of those pages of memory only contain initialization information that the process will never touch again.
The computer could keep that information in physical RAM forever. But that would be a complete waste as the data will never be used.
So the computer moves memory that has not been used for a very long time to swap. This creates more free physical RAM, which allows a larger disk cache and better performance.