What is the function of this cable surrounding the CRT of old televisions
It's part of the degaussing system.  "Degaussing" refers to removing any residual permanent magnetic field.  This is important because electron beams are deflected by magnetic fields.  Residual magnetism in parts of the unit can cause strange abberations and color fringes in the picture.

To degauss the unit, a strong AC current that gradually diminishes is run thru a large coil.  What you see is part of that coil system.  The AC current causes a varying magnetic field.  This pulls and pushes on anything that might retain a small permanent residual field.  These pulls and pushes are gradually made weaker so that in the end the residual field in anything that might retain one has converged to zero.

The degaussing "control system" was often just a positive temperature coefficient thermistor in series with the coil, and that connected directly to the AC line.  When first turned on, the thermistor is cold and conducts a lot of current.  This warms it up, so that it gradually conducts less current thru the coil over a number of AC line cycles.

You can often hear a short hum from these TVs right after being switched on.