The testicles hang in the scrotum by the spermatic cord. They are outside the body because they need to be cooler than the temperature inside the body, in order to make sperm. If a man's testicles get cold, they are automatically pulled closer to the body. The "spermatic" cord is tightened by the cremasteric muscle. When this muscle "contracts" (pulls tighter), the cord gets shorter, which pulls the testicles closer to the body. If the testicles are too warm, the cremasteric muscle "relaxes" (gets longer.) This lowers the testicles to keep them cooler. This is how the testicles are kept at the right temperature. This is called the "cremasteric reflex". (A reflex is something your body "automatically" does without you thinking about it.)