Why exactly would a doctor tell you that you can't have sex during pregnancy?

My doctor said I shouldn't have sex as I have had a miscarriage in November...but why? I miscarried early...if my uterus is ok n my cervix is competent why? It's been almost two weeks and I need an attitude adjustment!