In the case of Acoustic:
The density of the wood affects its resonance. the sound is echoed inside the hollow base and the quality of the wood affects how much sound is distributed outwards. The same effects are applied with damp wood, if the wood is damp it will affect the sound.
In the case of Electric:
I am unaware of any effects the wood has on the sound or quality of the guitar, its mostly down to professional appearance and finish. also the better the wood the longer the guitar will last and more of a beating it can take.