"Because Hashem, your G-d goes in the midst of your camp to save you and put your enemies before you. Your camp must be holy! He must not see in you any matters of immorality, or He will turn around from behind you." (Ki Saitzei)
Bilam understood this very well. When Bilam was not allowed to curse Bnei Yisroel, he advised the Moavim to send out their daughters to entice the Jewish men. "The G-d of the Jews despises immorality. If you can cause them to be nichshal, G-d Himself will punish them for you."
We live in times where there are so many tzaros. We cry out to Hashem to help us, and sometimes we think He is not listening. We were warned: If Hashem sees among you immoral things, He will turn around and forsake you. Our job is to bring the Sh'chinah back to us by living up to His standard of purity.