in the days before bathrooms people bathed in a tin bath in front of the fire....the expression comes form the concept of disposing of something useful (the baby) as you dispose of something you dont want (cold dirty bathwater)
When people used to only bathe once a week, all the family had a bath on the same night. The father would be first then it would go down in the family, the baby being the last one to have a bath.
as an addition to clairef33 when all the family had finished bathing the baby was last and oftentimes the water was dirty and the baby would go un-noticed and be throwen out.