Here's the answer and all you have to do is read it in scripture
“God spoke to Moses, saying, 'Take the staff and assemble the congregation, you and your brother Aaron, and speak to the rock in their presence so that it will give forth its water. You shall bring forth water for them from the rock, and give the congregation and their livestock to drink.'
“Moses took the staff from before the Lord as He had commanded him. Moses and Aaron assembled the congregation in front of the rock, and he said to them, 'Now listen, you rebels, can we draw water for you from this rock?'
“Moses raised his hand and struck the rock with his staff twice, when an abundance of water gushed forth, and the congregation and their livestock drank.
“God said to Moses and Aaron, 'Since you did not have faith in Me, to sanctify Me in the eyes of the children of Israel, therefore you shall not bring this assembly to the Land which I have given them.'"
What exactly was Moses' and Aaron's sin? What did they do wrong?
God told Moses to speak to the rock. Instead, Moses struck the rock (his brother Aaron complied). It was this error of Moses that prevented him from entering the Holy Land.
Want more about the reasons why? I’ll write a hub on it.
8. Take the rod, and gather thou the assembly together, thou, and Aaron thy brother, and speak ye unto the rock before their eyes; and it shall give forth his water, and thou shalt bring forth to them water out of the rock: so thou shalt give the congregation and their beasts drink.
11. And Moses lifted up his hand, and with his rod he smote the rock twice: and the water came out abundantly, and the congregation drank, and their beasts also.