Thank you for your question.
When you are rhesus negative and your partner is rhesus positive it is possible that the fetus also has rhesus positive antigen. If so any blood that leaks into the mothers circulation can trigger an immune response causing antibodies to cross the placenta and make the baby anaemic. Anti D during pregnancy at 28 and 32 weeks prevents such antibodies forming during pregnancy. After you deliver the baby's group and rhesus status can be checked and Anti D given if baby is rhesus positive. This protects your future pregnancies too.
This is a simple explanation. Hope it helps.