the better question is why did God deliver so many people into captivity/slavery if he was with them? unless he wasnt with them
Isaiah 49:24-26
You have to have faith to believe the reasoning. If they don't have faith, then its no need to discuss that with them.
But even if you don't have faith, you can read a passage and understand that if you dont obey, then you get punished.