These 2 temples were destroyed, because the people of Israel had turned from following God. God had warned Israel many times in the Old Testament, what would happen to them if they didn’t serve him. For example:
1 Kings 9:6-9 But if you turn aside from following me, you or your children, and do not keep my commandments and my statutes that I have set before you, but go and serve other gods and worship them, then I will cut off Israel from the land that I have given them, and the house that I have consecrated for my name I will cast out of my sight, and Israel will become a proverb and a byword among all peoples. And this house will become a heap of ruins. Everyone passing by it will be astonished and will hiss, and they will say, ‘Why has the LORD done thus to this land and to this house?’ Then they will say, ‘Because they abandoned the LORD their God who brought their fathers out of the land of Egypt and laid hold on other gods and worshiped them and served them. Therefore the LORD has brought all this disaster on them.'”
So the first temple was destroyed because Israel did not keep God’s commandments but served idols.
Jesus predicts the destruction of the second temple in:
Matthew 24:1-2 Jesus left the temple and was going away, when his disciples came to point out to him the buildings of the temple. But he answered them, “You see all these, do you not? Truly, I say to you, there will not be left here one stone upon another that will not be thrown down.”
Luke 19:44-47 “And they will not leave one stone upon another in you, because you did not know the time of your visitation.” And he entered the temple and began to drive out those who sold, saying to them, “It is written, ‘My house shall be a house of prayer,’ but you have made it a den of robbers.” And he was teaching daily in the temple. The chief priests and the scribes and the principal men of the people were seeking to destroy him.
The Jewish leaders had made God’s temple a den of robbers, and they were seeking to destroy Jesus. This is an indication of the falling away from the true worship of God that had occurred in Israel. Jesus’ comment in John 3 confirms this situation:
John 3:19 And this is the judgment: the light has come into the world, and people loved the darkness rather than the light because their works were evil.