In Moses' time than God had promised him that he would go into the promise land right but then later when Moses strikes the rock twice and water comes out then god says that Moses will not Lead the people into the promise land because how can Moses be an example if he does not obey himself but what I don't get is if God said Moses wouldn't lead his people to the promise land wouldn't God not be keeping his promise? And I don't get how Moses disobeyed by hitting the rock twice?
God promised to bring the people of Israel to the promised land. "I have said I will bring you up out of the affliction of Egypt to the land of the Canaanites and the Hittites and the Amorites and the Perizzites and the Hivites and the Jebusites, to a land flowing with milk and honey" (Exodus 3:17). This promise wasn't specifically to any one person, but the nation as a whole. But it never was a given that God would bring people no matter what. People were expected to obey God.
Moses and Aaron lost the privelege of the entering because they disobeyed God.
"Then the LORD spoke to Moses, saying, "Take the rod; you and your brother Aaron gather the congregation together. Speak to the rock before their eyes, and it will yield its water; thus you shall bring water for them out of the rock, and give drink to the congregation and their animals." So Moses took the rod from before the LORD as He commanded him. And Moses and Aaron gathered the assembly together before the rock; and he said to them, "Hear now, you rebels! Must we bring water for you out of this rock?" Then Moses lifted his hand and struck the rock twice with his rod; and water came out abundantly, and the congregation and their animals drank. Then the LORD spoke to Moses and Aaron, "Because you did not believe Me, to hallow Me in the eyes of the children of Israel, therefore you shall not bring this assembly into the land which I have given them" (Numbers 20:7-12).
Moses made two mistakes: He added to God's command by striking the rock even though God didn't say anything about it. But worse, Moses said that he and Aaron were bringing forth the water. He did not give God the credit. Because of their sin, they lost the privilege of entering the land of Canaan.
This is an important lesson for all of us. No one is so important that God must save the person. We are all promised a place in heaven. "For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life" (John 3:16). But we are expected to be obedient to God. "For who, having heard, rebelled? Indeed, was it not all who came out of Egypt, led by Moses? Now with whom was He angry forty years? Was it not with those who sinned, whose corpses fell in the wilderness? And to whom did He swear that they would not enter His rest, but to those who did not obey? So we see that they could not enter in because of unbelief. Therefore, since a promise remains of entering His rest, let us fear lest any of you seem to have come short of it. For indeed the gospel was preached to us as well as to them; but the word which they heard did not profit them, not being mixed with faith in those who heard it. For we who have believed do enter that rest, as He has said: "So I swore in My wrath, 'They shall not enter My rest,'" although the works were finished from the foundation of the world. ... Let us therefore be diligent to enter that rest, lest anyone fall according to the same example of disobedience." (Hebrews 3:16-4:3, 11).