Rebbe Chachinai says: One who stays awake at night, and one who goes on the roadway alone, and one who turns his heart to time-wasting – he is liable for his life.
After the Tanna has taught the virtue of one who is involved in Torah [study], and the flaw of one removes himself for the study of Torah, he teaches us the present lesson. What is being taught is as follows.
G-d arranged the world in an appropriate way, and arranged a system for the world to be under His watch. But there are things that can remove man from this system (depriving him of this protection). It is in this context that the Tanna teaches that one who removes himself from the order which provides Divine protection is liable for (the loss of) his life.
The first is one who remains awake at night. Since night was created for either sleeping or learning Torah, as we are taught in Masechet Eiruvin (65a), one engaged in either of these activities is under the protective eye of G-d. This is because he has deposited his soul [with G-d] as it is written “In Your hand I entrust my spirit, you redeemed me, G-d of Truth” (Tehillim 31:6).
But the soul of one who remains awake all night is not given over to G-d. And since forces of destruction (“mazikin”) are given permission to exert control during the night (see Rashi on Shemoth 12:22) the person who remains awake at night has removed himself from the normal order of the world, which includes Divine supervision.
Similarly, one who turns his heart to time-wasting, even in the daytime, has deviated from the natural order of the world. This world was created for man to accomplish and create, and no resource is to be wasted. Everything is supposed to be useful and purposeful. Within this orderly system, everything is under G-d’s watchful eye. But one who turns is heart to time-wasting is seeking ways to waste time (removing himself from the system in which G-d watches us). There is a distinction, however, between one seeking time-wasters and one who remains awake at night, even though neither one of them is studying Torah. The person who remains awake at night, as long as he isn’t seeking ways to “kill time,” is ready (at least in potential) to be involved in some productive activity. His only problem is the deviation from the standard purposes for which night was created, which deprives him of the standard protection the natural order provides.
What about a person who is involved in productive work at night, even though he isn’t actually studying Torah? Since “all Torah that does not have work accompanying it is ultimately nullified” (Avoth Ch. 2, Mishna 2; see the Maharal’s commentary) work which is necessary in order to support Torah (his or that of others) is not included in the law of this Mishna. The development of the world is itself a mitzvah (so working at night would not deprive the person of the natural protection inherent in the worldly order, even though he is not sleeping).