Jesus announces this beatitude in the middle of his description of Armageddon. So it is connected to his second coming, which will come suddenly (the picture of a thief breaking into a building is used frequently in the New Testament connection to the second coming of Jesus). The beatitude is a warning to his disciples and he uses the picture of clothes to make his point.
A thief is successful because the owner of the house falls asleep. When the owner wakens, he discovers his clothes placed elsewhere have been taken and he has nothing to wear. If he had not gone to sleep, his loss would not have occurred. The lesson is that Christians should not succumb to spiritual sleep. Instead they should always have on their spiritual attire.
The church in Laodicea, which had fallen asleep in a spiritual sense even although it imagined that it was wide awake, was exhorted by Jesus to buy from him ‘white garments so that you may clothe yourself and the shame of your nakedness may not be seen’ (Rev. 3:18). I doubt if this is a reference to the garments of justification because possession of them does not fluctuate. Instead it refers to sanctification or to Christlikeness, which does have degrees, and which can at times be less than at other times. Times of difficulty can be difficult times for making progress in sanctification. When they come along, we should remember this beatitude and put on our best clothes.