It is an inductor and is used to block high frequency (pulse) noise generated by the motor (mainly from the brush/commutator sparks) travelling along the connecting wires and being radiated as EMI (which may cause interference to the RC receiver or nearby radios/TVs). The small chip capacitors mounted on the motor PCB do a similar job of reducing the motor noise by shorting them to the can (each wire has its own capacitor to can, plus one across the wires).
Although the coils are there to reduce interference, they do smooth the PWM signal very slightly (round off the sharp edges), but they (and the capacitors) would have to be much bigger to do this properly.