God hated the idolatry of the Canaanites who worshipped Baal. For that reason, He commanded the Israelites under Joshua to kill every pagan Canaanite man, woman, child and even beast for they were impure in the eyes of God. When one of Joshua's general failed to fully obey this strict order by sparing the animals (possibly believing they could be of good use for the Israelites), Joshua had him executed right away.