We are born into this world as mature spiritual beings rather than immature spiritual beings. The soul can choose to enter the mother's body at any stage during her pregnancy. Miscarried births or babies who survive only a short time are fulfilling a purpose. Such souls do not need the development that a long life would bring. Their deaths provide challenges that help their parents grow.
Miscarried babies are able to appear as babies in the afterlife.
By miscarrying, these souls have fulfilled their purpose to absolute perfection. They do not remain as babies, however, and they will grow to maturity immediately upon entering the afterlife. We have all volunteered for our positions in life, and each of us is receiving more help than we are aware of.