As Luke points out, the ultrasound is very safe. However, in many cases it is not required. Typically by 20 weeks into the pregnancy, and sometimes earlier, a baby's sex can be determined by examining the genitals via ultrasound. My experience is that this is the most common reason for an ultrasound during pregnancy.
Of course if there are complications during the pregnancy, an ultrasound might be helpful to visualize the fetus and diagnose any problems. However there is no definite _need_ for an ultrasound during the course of a normal pregnancy.