It comes from the time when tradesmen carried all their worldly goods and tools around in a sack.You could say they were of no fixed abode, so if they were employed in a certain building they were able to leave their sack in a safe place, probably equivalent to the boss's office nowadays. If at the end of the day they did good work they were allowed to pick up their own sack, however if the boss was not pleased with their work, or felt they had not done a fair days work for a fair days wage then the boss waited for them to finish for the day and literally 'gave them the sack'.Whether the boss was generous enough to give them any leaving pay was up to him.