This episode starts off with Balaam refusing to curse the soon to be invading Israelite army because he just happens to have the same god as them ... somehow. It doesn't end well for him in that he's actually murdered by said invading Israelite army.
Why did the Israelite army attack in the first place, other than that just being their MO back then? Well some Israelite man had the gall to fuck a Midianite woman INSIDE HIS OWN HOME! Now luckily, a priest had the quick thinking to kill both of them while they were fucking, so God only murdered 24,000 Israelites instead of more of them. After all of this, they decided they needed to slaughter every Midianite woman, man, and boy, as well as burn down all of their houses. What happened to the girls, you ask? They kept them for sex slaves... well most of them... A few of them they sacrificed to God alongside a few hundred animals. Fun stuff!