How and what kind of noise can an optoisolator filter?
Then I used an optocoupler an the ringing completely disappeared.


You applied a load at the end of the cable and found that it reduced transmission line reflections to a reasonably low level. This shouldn't mean: -


  This made me believe that the optoisolator really works good for long
  distances.


That would be an incorrect assumption based on your observation. When sending pulses down a cable, to avoid reflections and ringing you use a cable terminating resistor. The opto removed excess energy from the signal as it came across what would be an open circuit and the load that the opto supplied made things better.


  One thing I can see that it separates the ground of the source and the
  receiver. But that would I guess only take care of the 60/50Hz ground
  loop noise.


That is a pretty good reason for using an opto coupler - it also prevents destructive earth fault currents passing through sensitive measurement apparatus. It is an effective counter-measure to common-mode noise or interference.