Every cell in our body has markers, to help the body recognise it as friend, not foe. If a cell appears in the body (e.g. bacteria) that the body does not recognise, the body creates antibodies that attack the cell(s). One of the markers on most of our red blood cells is called Rhesus (because it was first discovered in the Rhesus monkey). About 85% of the population is Rhesus positive (have the marker). If a woman has red cells without the marker (Rhesus negative), and she carries a baby with red cells that have the marker (Rhesus positive), she can be exposed to these cells and create antibodies to them. In a future pregnancy she will then attack the fetal blood cells (if the fetus is rhesus positive) and make her baby anaemic (low blood count). Clearly this can be very dangerous, and may require blood transfusions while in the womb and after delivery.
Anti-D injections contain readymade antibodies, which mean that the woman doesn’t have to make her own antibodies (which have a memory and can therefore affect later pregnancies).
It is recommended that every woman who is Rhesus negative should have Anti-D injections at about 28 and 34 weeks into the pregnancy, and after any bleeding or invasive procedure.