I think people say that to try to console someone when there isn't any ready answer to give them. Because people need to know why misfortune has befallen them. 'Why, oh, why did this happen to me??? Tell me!!' There are a number of things people might tell the person under those circumstances including the old 'it wasn't meant to be.' It's probably a very old phrase, been around for a very long time.