No sex?

What’s the reason for the doctor to say no sex while pregnant if it doesn’t cause miscarriages?