Final answer:
The cremaster muscle controls the temperature of the testes by moving them closer to or farther from the body depending on the environmental temperature.
Step-by-step explanation:
The function of the cremaster muscle in the male reproductive system is to control the temperature of the testes. This is crucial for sperm production, as sperm require a precise temperature to develop properly. The cremaster muscle acts in concert with the dartos muscle to elevate the testes towards the body to warm them when cold, or to relax and allow the testes to hang away from the body to cool them when the environmental temperature rises.