What is the purpose of a mains X2 Security Capacitor and how to determine its value?
Class-X and Class-Y capacitors are safety-certified capacitors generally designed and used in AC line filtering in many electronic device applications. These safety capacitors are also known by other names, including EMI/RFI suppression capacitors and AC line filter safety capacitors. (EMI stands for electromagnetic interference and RFI stands for radio-frequency interference; RFI is simply higher-frequency EMI.)

So, Class-X and Class-Y capacitors help to minimize the generation of EMI/RFI and the negative effects associated with received EMI/RFI. They are classified according to their peak voltage/rated voltage and the peak impulse voltage that they can safely withstand.