Q. Peter clearly states in his second letter that “God is not willing that any should perish, but that all should come to repentance.” Several statements in the Bible that seem to be contrary to this don’t make sense to me. Two examples are Joshua 11:20, “The Lord hardened their hearts . . . that they might receive no mercy,” and John 12:40, “He has blinded their eyes and deadened their hearts so they can neither see with their eyes, nor understand with their hearts, nor turn, and I would heal them.” Wouldn’t God want to make it easier for all of us to get to Him? So why would God discourage some people from believing or make it harder for them than for others? Related to this is the way people or nations had their hearts hardened so that God could demonstrate his power. Pharaoh seemed ready to let the Israelites go, but instead God hardened his heart and the plagues came, including death to all the first born.
Thank you for these excellent questions. I’ll take some time to answer them. In this post I’ll talk about the reference in Joshua to God hardening hearts and showing no mercy. In my next post I’ll take up the passage you cite from John. And in a final post I’ll look at the hardening of Pharaoh’s heart.
The question of people and nations being hardened, so that they are destroyed rather than saved, comes up several times (quite understandably) in my study guide to Joshua, Judges, and Ruth. As I tell groups when they first read through Joshua, “This aspect of the book . . . creates one of the greatest difficulties in the entire Bible for thoughtful, compassionate followers of Jesus.” So let me begin answering your question by sharing what I say about it in the Joshua study guide. I’ll take up the passages you cite from John and Exodus in subsequent posts.
In Session 4 of the guide, when groups consider the destruction of the city of Jericho, when no one is spared except Rahab and her family, I offer these observations:

“The Bible sometimes describes judgments of total destruction like this, but at other times God’s judgments are limited and tempered by mercy. The challenge for readers of the Bible is to determine which kinds of episodes are normative and which ones are exceptional, and why those occurred.
Jesus’ life and teachings provide, for his followers, the interpretive key to the entire Scriptural record of God’s dealings with humanity. In light of them, believers identify what things are normative and what things are exceptional.
Jesus taught that we should love even our enemies, and that we should show mercy to others so that we will receive mercy ourselves. He died to save people who were, at the time, his own enemies. So his life and teachings show that judgments of total destruction, like the one described here, are exceptional. So why did exceptional events like this occur as the Israelites took possession of Canaan?
“This is a question that thoughtful interpreters have offered different answers to, but here is one possibility to consider. It may be that God had determined that Canaanite society had become so corrupt that it couldn’t be redeemed. This society was particularly violent, oppressive, and degraded. . . . If this society was never going to change, then it had to answer the demands of justice. Moreover, if the Israelites imitated the Canaanites, they’d rapidly be corrupted themselves. So their influence had to be removed completely.
As God had earlier used flood and fire to purge away irredeemably wicked societies from the earth, now God chose to use the Israelite armies for this purpose. This was not an ordinary war; these armies were on special assignment as agents of divine judgment. This is why, in the case of the opening battle of Jericho, the soldiers weren’t allowed to take any plunder.”
I then invite groups to interact with these comments, to say whether they think they might be on the right track, even if they don’t completely agree with them, or whether they’d account for episodes like this one in some other way.
Then, in Session 7, groups take up the part of Joshua that summarizes the conquest of the nations living in Canaan. There we find the statement that you asked about: “It was the LORD himself who hardened their hearts to wage war against Israel, so that he might destroy them totally, exterminating them without mercy.” When we read this statement on its own, it does sound as if God wanted all the Canaanites to perish, in direct contradiction to what Peter writes. But we need to understand this statement in its context. I suggest the following in the Joshua study guide:
“The author’s primary concern here is to document that Joshua faithfully carried out what ‘the LORD commanded Moses.’ Canaanite culture was so corrupt and oppressive that God didn’t want it to supply any part of the model on which the new Israelite society would be built. But this meant that Canaanite influence had to be completely eliminated.
So God led the Canaanites ‘to wage war against Israel so that he’—Joshua—’might destroy them totally . . . as the LORD had commanded Moses.’ The fundamental goal is the complete removal of the corrupting Canaanite influence, so that a new society can be built on God’s laws, as a model for the rest of the world. Everything else–the hardening, the war, and the destruction–follows from that.”
If this is the case, then paradoxically the indirect but ultimate goal here is to make it possible for people to follow God, not to prevent them from doing so. And so, as I observe further:
“If the ultimate goal is to make it possible for the Israelites to model God’s ways for the rest of the world, then it’s consistent with that goal for some people outside Israel, at any point, to choose in favor of God. But this means that the hardening must have been general, on the Canaanites as a whole, and not specific, in each one of their individual hearts. (The text uses the collective singular: ‘It was from the LORD to harden their heart.’) To seek the God of Israel, an individual person or city would have to make a choice contrary to what everyone around them wanted to do. In this culture of corporate identity, this would not have been easy. But as the cases of Rahab and the Gibeonites show, it wasn’t impossible.”
Indeed, if we understand the episodes of total destruction in the book of Joshua by analogy to the judgment of the flood, then only the earthly destiny of the Canaanites was at stake, not their eternal destiny. In an earlier post I’ve explored the biblical statement (also by Peter) that Jesus went and preached to the imprisoned spirits who perished “in the days of Noah.” This is only speculative, I must emphasize, but it’s possible that the spirits of those who perished “in the days of Joshua” might also have been “imprisoned,” awaiting a proclamation of the gospel that they could understand from Jesus himself.