What we DO know for sure is that God is all-good, and all-just.
THIS^^^. We know this of faith
a priori, and so whatever God allows is all good and all just. THIS we know with absolute certainty. We're much less certain about why any particular incident was allowed by God for good. Simply because we can't figure out why, with our pea brains, there's no reason to interrogate God over it. [As an aside, this is one of my biggest issues with Baptism of Desire speculation, that much of it is rooted in this notion that it would be "unfair" or unjust or unmerciful for God to allow someone to die before Baptism. Or why did God allows millions of souls in the New World to never hear the Gospel until the 15th century?]
Not only did God perhaps allow a miscarried baby to enjoy perfect happiness for all eternity in Limbo when he might otherwise have ended up in hell, but perhaps other people's souls were touched and effected in certain ways by what happened. God knows how all things are connected, past, present, future. Something that happens now might have ramifications in 100 years. Only God's intellect grasps it all. I know certain things that happened in my life where, at the time, I had no idea how it could be good (not that I doubted it) ... but that I actually realized many years later the fruit that came of it. "Oh, NOW I get why all that happened." We won't always figure it out in this life, but we'll see it all clearly in the next.
Our Lord told Judas that it would have been better for him had he never been born. In the case of miscarried or aborted babies, God has judged that it was better that they never be born. In addition, the sorrow of others who experience the miscarriage, say the parents and relatives and friends, might move their minds and hearts to compassion.
Occasionally we read of some horrible thing that has happened to a little child, and there's an outpouring of compassion (and indignation) all over social mєdια. While the child suffered, how many people were moved to compassion and other virtuous thoughts and feelings as a result. Also, the suffering may benefit the victims in terms of their eternal fate.
People act as if suffering and pain is evil. No, it's not. Take the example of those people born with a defect that they can't feel pain. They have very difficult lives. They regularly incur third-degree burns because, say, the put their hands on a hot stove and don't realize that they're being burned. When we suffer sports injuries and end up limping due to pain. Well, the pain is calculated to deliberately make you favor the injured area to prevent further injury. I can't put my full weight on a sprained ankle. But if I didn't feel pain to prevent me from doing that, I'd be liable to injure it much worse by not favoring it.
Take for example how aborted babies suffer great torture in abortion. How could that be good? Well, imagine if abortion was entirely painless. That would undoubtedly take a lot of steam out of the Pro Life movement, making it much more difficult to persuade people that abortion is evil. How many women have NOT gone ahead with an abortion solely because of the pain it would inflict on the unborn child who perhaps wouldn't have given it a second thought if it were entirely painless.
No, the only true evil is sin.