On the origin of quantum mechanics