What is the use of magnets around electrical cables?
They're not actually magnets, but rather ferrite which is a paramagnetic material.  A ferrite bead with a conductor through it is an inductor and so is used as a low pass filter.  Typical use is for power cables to reduce EMI (electromagnetic interference).