Before a rover or other exploration vehicle is launched, it undergoes rigorous cleaning and disinfection, such as a bath in UV rays to kill off bacteria.
The official reasoning on this seems to be that the bacteria on the vehicle (deposited by people touching it, spiders on the ceiling, whatever), may cause a false positive for life on the other planet by "riding" the vehicle to space and leaving the vehicle for the other planet. There, it would colonize. We would later detect it and say that it's a sign that life exists there.
However, my understanding of this answer is that cosmic radiation will take care of it on its long journey:
It appears that most of the true sterilization actually takes place after launch. The harsh conditions of the trip there and the landing should be enough to kill off a majority of the microbes.
The Mars rover projects all receive multiple sterilization treatments here on Earth before launch, typically UV treatment, but what really kills off the bacteria is the exposure to cosmic radiation on the trip over and the intense UV radiation on Mars' surface.
If cosmic radiation will kill it all off anyway, what is the real risk to leaving life on a spacecraft headed for another planet?