Israel killed the Midianites, including Balaam, for tempting them to worship Baal. This battle was at Yahweh's command. Yahweh would bring justice.