Miscarriages occur mostly within the first trimester, although of course they can occur during the second and third trimester as well. 10-25% of all pregnancies will end in miscarriage, and some of those miscarriages will occur so early that a woman believes it is her menstrual flow - this is called a chemical pregnancy, and it's around 50-75% of those miscarriages. But they occur mostly in the first trimester due to the body recognizing something is usually not right with the growing embryo - most spontaneously aborted pregnancies tend to have either genetic or other medical abnormalities which would prevent the embryo from dividing/growing properly in utero.
There are also different types of miscarriages a woman can experience, from an ectopic pregnancy and molar pregnancy, to an incomplete miscarriage and a missed miscarriage.
There have been studied that show most miscarriages affect male embryos, and the mother's immune cells can indeed see a male embryo as "foreign," and work it's hardest to expel it. Women who have had male children do indeed, more often than not, have immunity cells within their body that were created to act upon their male children in utero, as well as have more pregnancy-related complications with pregnancies after giving birth to a boy:
In truth, much more can go wrong with a developing male embryo than a female embryo.
Some cool studies:
Male fetuses are particularly affected by maternal alloimmunization to D antigen:
http://onlinelibrary.wiley.com/doi/...sCustomisedMessage=&userIsAuthenticated=false
Secondary recurrent miscarriage and H-Y immunity:
http://humupd.oxfordjournals.org/content/17/4/558.long
--------
So, there's a little science behind miscarriage. Before I get called a "sexist," and green73 quotes me with his usual "you seem to have a low opinion of men, why do you stick around?" I just want to point out that autoimmunity was a subject I studied for my honors thesis, which I coupled with my degree - reproductive biology, so it's just random knowledge I remember that I thought I'd share.
As for the emotional aspect of abortion... I can't honestly have an opinion, and I would feel wrong to have one. I have never been pregnant or lost a pregnancy. I do know some women take their miscarriages better than others. I know some women are extremely distraught after a miscarriage (I've had those EMS calls), and I know there are women who believe it to be God's will, and while they are sad about it, they work through it. Anyway, I'm not going to sit here and pretend to know the "right" way to handle a miscarriage.