What’s the point in covering the viewfinder?

Recently, I found out that the rubber cover on the strap of my Canon EOS camera is used to cover the viewfinder. I searched on the web to learn why should I cover the viewfinder and I read that it prevents light passing through the viewfinder and somehow getting to the sensor.

  • Is this true?
  • If it is, how does light get to the sensor? Doesn’t the mirror prevent that?