Kids often need some time to get used to the idea of having a sibling, or they may have been excited right away. Whatever the case, it will be confusing for them that mommy was expecting a baby, and now she isn't anymore. For some children, their mom's miscarriage will be their first encounter with death. Many people decide to wait until the first trimester of pregnancy has passed to inform anyone, including their children, about their pregnancy. This is the time that the risk of miscarriage drastically goes down. However, kids may have noticed that you were feeling rough and may have had morning sickness, or you were just too excited not to tell.
You can explain that pregnancies don't always work out and that, just like people and pets can die, this can happen to babies in mom's tummy as well. If you believe in God, you can tell your children that the baby went to heaven if you are comfortable with that. You can also show them books about pregnancy and the development of a fetus. Death is always a complicated subject with small children, and miscarriage is no different. Many parents find that telling the child as much as they ask, and not giving them more information than they are curious about themselves, is a good approach. You can start by giving very simple answers to your child's questions, and then going into more detail if they ask more.