Do mutations happen at random or do they occur based on the needs of survival in the environment? That is, does the environment cause the genetic mutation or do tons of mutations happen randomly and get selected based on its survival value. Or perhaps the random mutation happens to be the one compatible with means for survival and over time continues surviving?
That being said, how does a species die out naturally if already equipped to survive according to its genetic code?