Why did Israel wander for 40 years?

First spies sent in to see the land lied, said people were giants. God then punished them by making them wait until that generation had died out.