"Embryo implantation sets off a process that ultimately turns off a key pathway required for the immune system to attack foreign bodies. As a result, immune cells are never recruited to the site of implantation and therefore cannot harm the developing fetus."
...
"it gives a satisfying explanation for why the fetus isn't rejected during pregnancy, which is a fundamental question for the medical community" - https://www.sciencedaily.com/releases/2012/06/120607142244.h...
Have a google around for similar papers. It's a fascinating topic that we've only begun to fully understand in the last decade or so.