Science fiction stories sometimes describe equipment that has a self destruct button. This is sometimes a precaution to prevent important information or technology from falling into enemy hands. God created man to live forever in a state of holy communion with Him (Gen 1-2), but man made the choice to sin (Gen 3, Ecc 7:29). It is not the desire of God to see man destroyed (Eze 18:32, Eze 33:11, 2Pet 3:9), but man must be held responsible for his actions (Rom 14:12). God did not install a self destruct button in man. Man installed one in himself by sinning (Gen 2:17, Eze 18:4 & 20, Rom 6:23). Now our natural tendency is toward sin, not righteousness (Jer 17:9-10, Mt 15:18-20, Rom 6-8). It takes empowerment from God and effort from man to produce good.
We choose to push and activate our self destruct button when we sin. The only way to diffuse it is to repent and be born again (Lk 13:3-5, Jn 3:3-5, Acts 2:38). The Moabites were the descendants of Abraham's nephew Lot (Gen 19:37). When the Israelites were delivered from Egypt and were passing through the wilderness en route to the promised land, they were not far from the land of Moab. God told Moses not to distress or contend in battle with (Deut 2:9). Yet when they passed by, the Moabites were very afraid of them and hired the soothsayer Balaam to curse them so they could defeat them in battle (Num 22:3). This did not work because God prevented it (Num 22-24). So the Moabites got Israel to hit their own self destruct button by luring them into idolatry and fornication (Num 25). What Moab and Balaam did not realize was that they were also pushing their own self destruct button (Num 25:17-18, Num 31). None of this had to happen. God was protecting Israel and Moab, but they both chose destruction over God's goodness.
Some people question and accuse God when bad things happen. It is not God but us who hit the button. God does have the right to judge us individually and collectively (Rev 20:11-15), but He does not make our choices. God does not diminish when we sin. We do. God does not withhold good things from His children (Josh 21:45, Ps 34:10). That was the lie the serpent told Eve (Gen 3:1-7). What God forbids is only that which will destroy us. He loves us wants what is best for us.