Why would God allow something like these terrorist attacks to happen?
God made a decision at the beginning of time, not to create robots, but to create human beings with the ability to make moral choices. Since we are not robots who are programmed only to do good, we are moral beings with the ability for good and the possibility of evil. If one chooses evil, there will be consequences of that evil.
For example, if I choose to hit you in the face, my evil will cause you pain. That is the double-edged sword of being able to make choices.
Just because God made us with the ability to choose, does not make him responsible for the actions we take. I’ll use this analogy. God made this big road with all these exits. God has told us to drive on the big road and never get off on any exit. Now we get on the road - and some choose to get off of the road. God is not responsible for those people getting off on the exit. In fact He told them not to. Those people are responsible for their actions.
God is not responsible for humans’ sin. And it is sin that causes suffering.
But could God have stopped the attacks? Of course. So why didn’t He? All we can trust in is what he has said, “And we know that in all things God works for the good of those who love him, who have been called according to his purpose.” –Romans 8:28. The Bible is full of terrible things happening and something good coming out of it. For instance, Christ had to suffer and die for us to find reconciliation with God. Joseph had to go through slavery and prison to be elevated into power. The apostles were persecuted for their preaching of Christ.
We know why bad things happen – human sin. But we don’t know the details of why God doesn’t stop some of these things until later (and sometimes never). But we do know what God has promised. And that is what we put our faith in – God and his promises. That gives us hope.