We encourage our children to avoid strangers. Yet just as your baby is a "foreign body" to your immune system, you are a stranger to her--sometimes one who's just as dangerous as the sleazeball pulling over on the curb to offer her candy. Since reproduction isn't magic, but a complex system of rules and consequences, you can't always have everything. The host vs. graft reaction between mother and child comes close to blowing the whole thing.
Thankfully, good fences make good neighbors. The system by which your blood and your baby's remain separate, and the membranes that segregate your pregnancy from the rest of you act to maintain peaceful coexistence until delivery. But there are some holes in the system.
Antibodies you make can be small enough to slip through the exchange network to your child. Antigens, however, are usually attached to bigger structures, like red blood cells, and are too bulky to go from your baby to you. Your baby's red blood cells, usually different from the type you have (thanks to that big foreign body, your husband) don't get to you, and neither do the antigens they house. Consequently, you don't generate antibodies, which is good because those would be small enough to get back to your baby.
Why blood group incompatibilities have never been taught on Sesame Street is a mystery to me, because it's all ABC's. There are the main blood types, A, B, AB, and O. A is only A, which means it can't mix with B, AB (it'll fight the B-part of AB), or O (which sees both A and B as foreign). The same goes for B. AB can only mix with AB (AB will strike discord with A, for instance, by showing up with a hostile B-part). And lonely O can only mix with another O, seeing A, B, or AB as foreign.
They're called A, B, or AB, because they have the A-, B-, or AB- antigen that will generate an anti-foreigner response, and no one does well with a war going on inside of them.
There's also the CDE system. The D, in particular, is a concern because of its frequency and possible severity of consequence. True, ABO incompatibilites between you and your baby are frequent, too, but the response is usually mild, which keeps the UV light industry in business. When you see blue lights going in the nursery, this is called phototherapy, which will break down the bilirubin that's released in the blood war going on in your baby.
D incompatibility, however, can be very serious. This antibody is called the Rhesus D antibody, because of the initial research done with Rhesus monkeys. The C, c, E, and e are also in the Rhesus antibody group, but these are usually less severe. It's the D that's the problem.
If your baby ends up being Rh-negative, like you, then there's no problem. If you're Rh-positive, there's no problem. But if you're D-negative (Rhesus negative, or Rh-negative), that's fine until your blood first encounters blood that is D-positive (Rh-positive), usually when your blood and your baby's blood finally mix a bit with the sloppy blood-hit-the-fan phenomenon known as placental separation. Then all hell breaks loose in your blood stream. Fetal blood cells blunder into your system, evoking a lot of indignation that results in the production of your antibodies to fight them. They lose, but this is of no consequence, because your baby's out of the blood incompatibility picture, instead getting into the relatives' pictures at the nursery window. Your antibodies remain. So many antibodies and so little to do.
Until your next pregnancy.
Your antibodies, able to pass through to your next baby, do just that. As stated above, the ABO incompatibility is mild, but if you're Rh-negative and your baby is Rh-positive, you'll be sending your anti-Rh army into battle, and the battlefield is in your baby. His red blood cells which house the Rh-antigen will be attacked and over time your baby will become anemic. This isn't good in a baby who's trying to grow and mature. Fluid dynamics cause weird swelling reactions in his abdomen, and eventually such anemia can cause serious injury or fetal death. This condition is referred to as erythroblastalis fetalis, and is treated by giving your baby transfusions via ultrasound.
Another victory of modern obstetrics: today erythroblastalis fetalis is rare, because we give an injection, called RhoGam, to Rh-negative mothers of Rh-positive babies. RhoGam is also an anti-Rh-positive antibody. When you get it, your body is fooled into thinking there's already been an adequate response and makes no antibodies on its own. The antibodies of RhoGam don't attack subsequent babies because they're much bulkier molecules and don't pass through the placenta to the baby. It's a pre-emptive strike that has reduced the risk of erythroblastalis fetalis to a negligible frequency.
In cases such as miscarriage, where the amount of mixing of blood is theoretical, there's a test called the Kleinhauer-Betke test (a blood test done on you) which can quantitate the amount of blood mixing that may have occurred. This is also useful with occasions of bleeding during a pregnancy as in mild, stable placental abruption.
There are other blood antigens you may have. These are rarer, and of these only a few put your baby at risk.
Once again, prenatal care rules.