It is because pets might carry worms that will cause deformed baby. It can be transmitted by touch of their waste.
I am pregnant and was warned by lots of people. I have started deworming my dog once a month but there is still chance that in between the deworming days she got caught with worms. Giving pets away is a lot easier I guess. I am not giving her away but I am being extra cautious.