Swap space is fake memory that is actually disk space.
The purpose of swap space is to be emergency overflow memory. Normally, if your server runs out of memory, the Linux kernel has to decide which processes to kill to free up memory. Often it's MySQL that gets killed first.
When you have swap space enabled and your server runs out of memory, the kernel can use swap space instead of killing processes to free memory. This means a temporary spike in memory usage won't crash your database or websites.
So, if you care about performance, don't rely on swap space. Instead, use a server with enough memory to handle your peak memory usage and keep your swap space for emergencies.