I'm pretty sure that in modern times, this is for the train conductor to keep track of who's going where, both to make sure that people don't overstay on the train and to wake the passenger up before their station.
But, being familiar with Soviet realities, I wouldn't be surprised if in Soviet times MastaBaba's answer was at least part of the story as well - i.e. to prevent people from getting off too early. (I'm not saying this is certainly the case, but it's a plausible theory). Keep in mind that some major train routes passed right by "closed" towns (e.g. one passes right next to the Baikonur spaceport in Kazakhstan). Also, a used train ticket (in both the old Soviet system and even in Russia today) is a much more serious/official document than a used train ticket or used boarding pass in Western countries. It is recognized by police, for example, to determine registration requirements (where you must register in any new place within X days of arrival) - so it's not just a matter of checking the ticket at the disembarkation station (which actually almost never happens), but a matter of not having proof of travel and proof of arrival date later on.
Actually, when I did the TransSib in summer of 2012 (on lots of local trains for chunks of the journey rather than one continuous trip), I haven't seen tickets being taken away for the entire journey in Russia anymore, but I did see this on some sleeper trains in China (conductor takes your ticket and gives you a temporary replacement card).