26 At that time Joshua pronounced this solemn oath: “Cursed before the Lord is the man who undertakes to rebuild this city, Jericho: At the cost of his firstborn son will he lay its foundations; at the cost of his youngest will he set up its gates.”
1 Kings 16:34
34 In Ahab’s time, Hiel of Bethel rebuilt Jericho. He laid its foundations at the cost of his firstborn son Abiram, and he set up its gates at the cost of his youngest son Segub, in accordance with the word of the Lord spoken by Joshua son of Nun.
Joshua had destroyed Jericho according to the will of God, as a symbol of what happens to people who practice unrepentant wickedness–it was one of the first sites in Canaan that was cleansed of sin in this way. Afterwards, he pronounces this curse on anybody who would try to rebuild Jericho as the great walled city it had once been, so as to keep the site dedicated to God.
But, inevitably, after a time, the Israelites forgot this as they forgot God, and in 1 Kings we see Hiel of Bethel rebuilding Jericho’s walls, paying for the sin of rebuilding a wicked city just as Joshua had decreed. (This all happened within the reign of King Ahab, who did nearly as much wickedness as the citizens of Jericho had.)
This is not a particularly comforting pair of Scriptures to read, but it makes an important point: God is Almighty, and has power even over the most powerful of men. When we act against Him, we will face consequences, stemming from divine discipline. Hiel’s sons die not because God worked an act of vengeance or evil, but because God disciplined Hiel for grasping at power. (Note: Joshua’s curse is not merely something spoken by man, but something coming from God, since Joshua led the “cleansing force” of the Israelites through Canaan to reclaim the land for God.)
So, when we purposefully do things that are against God, we should not then wonder why distressing things begin to happen in our own lives. This is not God being evil, because that is impossible; it is God disciplining us for going against Him, much as a parent disciplines a child for breaking rules. Sometimes God has to do fairly drastic things to get our attention, because we’re so bent on having our own way, but it is ultimately for our betterment, and for our realignment with God.