It's good to use if you're only going to be off for a short while. If someone snipes your TH or something, there is no danger of them also killing your hero and making them unusable for the next 1-3 hours.
Lets say you're about to raid, but have to make troops first and want to also use your barbarian king. Start making troops in the barracks, put your king to sleep and log off. This way if you get attacked in the mean time, you will still have your king ready for battle.