Exactly when you tell people you’re pregnant is entirely up to you. Some couples can’t keep the good news a secret and tell their families as soon as they find out, which can be as early as 4 to 5 weeks’ gestation. The good thing about telling people early is that there’s no need to make excuses for exhaustion and morning sickness, and you have people to support you in the event of a loss.
However, if you are concerned about playing it safe, i.e. minimising the risk of telling people about your pregnancy and then miscarrying, the best time to spill the beans is at 10 to 12 weeks’ gestation, at which point the risk of miscarriage drops dramatically. Between 10% and 20% of all known pregnancies end in miscarriage, and 80% of these happen in the first trimester (first 12 weeks) of pregnancy.
While there are many causes of miscarriage, it is very rare to find out why you miscarried, unless it happens 2 or 3 times, at which point you may be tested for genetic abnormalities that could be causing your immune system to reject the foetus as a foreign body.