All this happened because the Israelites sinned against the LORD their God, who brought them up from the land of Egypt, out from under the power of Pharaoh, Egypt's king. They worshipped other gods.
References for 2 Kings 17:7
They followed the practices of the nations that the LORD had removed before the Israelites, as well as the practices that the Israelite kings had done.
References for 2 Kings 17:8
The Israelites secretly did things against the LORD their God that weren't right. They built shrines in all their towns, from watchtowers to fortified cities.
They set up sacred pillars and sacred poles on every high hill and beneath every green tree.
References for 2 Kings 17:10
At every shrine they burned incense, just as the nations did that the LORD sent into exile before them. They did evil things that made the LORD angry.
They worshipped images about which the LORD had said, Don't do such things!
The LORD warned Israel and Judah through all the prophets and seers, telling them, Turn from your evil ways. Keep my commandments and my regulations in agreement with the entire Instruction that I commanded your ancestors and sent through my servants the prophets.
But they wouldn't listen. They were stubborn like their ancestors who didn't trust the LORD their God.
They rejected his regulations and the covenant he had made with their ancestors, along with the warnings he had given them. They followed worthless images so that they too became worthless. And they imitated the neighboring nations that the LORD had forbidden them to imitate.
They deserted all the commandments of the LORD their God. They made themselves two metal idols cast in the shape of calves and made a sacred pole. They bowed down to all the heavenly bodies. They served Baal.
References for 2 Kings 17:16
They burned their sons and daughters alive. They practiced divination and sought omens. They gave themselves over to doing what was evil in the LORD's eyes and made him angry.
So the LORD was very angry at Israel. He removed them from his presence. Only the tribe of Judah was spared.
But Judah didn't keep the commands of the LORD their God either. They followed the practices of Israel.
So the LORD rejected all of Israel's descendants. He punished them, and he handed them over to enemies who plundered them until he finally threw them out of his sight.
When Israel broke away from David's dynasty, they made Nebat's son Jeroboam the king. Jeroboam drove Israel away from the LORD. He caused them to commit great sin.
References for 2 Kings 17:21
And the Israelites continued walking in all the sins that Jeroboam did. They didn't deviate from them,
and the LORD finally removed Israel from his presence. That was exactly what he had warned through all his servants the prophets. So Israel was exiled from its land to Assyria. And that's still how it is today.