I heard on QI that the body spasms because humans used to live in trees and the body spasms because it thinks we are falling out of the tree while sleeping and the body attepts to grab something.
we would have had to have lived in trees for millions of years for that to happen, even then could we really evolve the ability to grab onto things while being unconcious