Consider these verses in which King David is told he will not be the one to build a temple:
“And David said to Solomon, My son, as for me, it was in my mind to build an house unto the name of the LORD my God: But the word of the LORD came to me, saying, Thou hast shed blood abundantly, and hast made great wars: thou shalt not build an house unto my name, because thou hast shed much blood upon the earth in my sight.” (1 Chron 22:7-8; also in 1 Chron 28:2-3)
The reason given is that David had “shed much blood.” What is interesting is that it was God Himself Who gave direction to much of King David’s war effort.
The first blood the Bible records David as shedding (other than perhaps bears and lions as he guarded the sheep) was that of Goliath. (1 Sam 17:49-51) But there was much more to follow; here are some examples:
“And there was war again. And David went out and fought with the Philistines, and killed them with a great slaughter. And they fled from him.” (1 Sam 19:8)
“And David smote the land, and left neither man nor woman alive, and took away the sheep, and the oxen, and the asses, and the camels, and the apparel, and returned, and came to Achish.” (1 Sam 27:9)
“And David enquired of the LORD, saying, Shall I go up to the Philistines? wilt thou deliver them into mine hand? And the LORD said unto David, Go up: for I will doubtless deliver the Philistines into thine hand. And David came to Baalperazim, and David smote them there, and said, The LORD hath broken forth upon mine enemies before me, as the breach of waters. Therefore he called the name of that place Baalperazim.” (2 Sam 5:19-20)
In the passage above (and there are others like it) God, it seems, was very much involved in Israel’s wars even giving directions like a general on the battlefield. Yet when it comes to the question of building a temple, God seems to be dissociating Himself from war. We also have this from the earliest days of the nation of Israel:
“And it came to pass, when Pharaoh had let the people go, that God led them not through the way of the land of the Philistines, although that was near; for God said, Lest peradventure the people repent when they see war, and they return to Egypt:” (Exo 13:17)
From that verse, it seems that it was never God’s intent that they experience war at all. So what is going on here? Is God doing a flip-flop over the question of the appropriateness of war?
For some great insights into this question listen to the message Navigating Evil (April 2016) by Ty Gibson of Light Bearers Ministry. At the 26:30-minute mark Ty really gets into the concept of the accommodation principle and goes through a few different Biblical examples including the one referred to above regarding King David.
See more on the accommodation principle in scripture.