An ultrasound is necessary because it allows the doctor to monitor and examine the health of the baby. With an ultrasound, the doctor can know if there's any swelling or infections inside the baby's organs or can diagnose the cause of pain if you're having any.
If you have a healthy pregnancy, then you'll most likely only need two ultrasounds. The first one is usually during the late first trimester, which can be from the 11th to 14th week. If everything is fine, then the second one can be from the 18th to the 20th week.