Rather than putting these used blades in the garbage can where children and others could accidentally handle them and hurt themselves, the shaver would remove the blade and stick it straight into this slot in the wall.
source: IS Architecture via WordPress/Life of Chestnut Street
The razor blades would just accumulate in the empty gap behind the wall. So if you’ve ever renovated an old home before and opened up a wall, only to find a pile of used razor blades behind it, this is why! Though this seems so peculiar to think about now, at the time, I can totally see why this design feature would be practical!