I was watching the video Video camera installed on rocket that reaches 121,000 ft., and this rocket has a cosmic ray detector. Why is this needed in a rocket?
It isn't needed in a rocket, however if you are going to the effort of sending something up outside the atmosphere (or even just high up within the atmosphere) you might as well try and get some useful data out of it. This might even help you get sponsorship for your rocket, as data from climbs through altitude is useful to a number of academic institutions.
You will also find many rockets taking thermometers and other devices for exactly the same reason.