According to modern research, sex does not pose a threat to your baby in early to mid pregnancy. However, doctors may advise you to avoid sex in later pregnancy, especially if you’re at risk of preterm labor or antepartum hemorrhage because of placenta previa (a condition where the placenta covers the cervix).
Sex can actually be beneficial during pregnancy. During sexual intercourse, an involuntary contraction of the muscles of the vagina and uterus is observed, preparing for future stresses during childbirth (i.e. those regular labor contractions). Sex may also improve sleep quality by increasing endorphins, which actively combat fatigue and other pregnancy-inhibiting symptoms.