this idiom stated in the early to mid 15th century, as personal hygine was nothing like it is today....somtimes bathing practices where where exercised once or twice a year....when it came to the family bath...the men /father , would bath first..in the same tub...mind you...and on down the line..sons, then women and the baby last!!...water being so dirty after the family wash party...that if not careful..you could "throw the baby out with the bath water"
Nowadays " don't throw the baby out with the bathwater " means not to dismiss an entire plan or idea that has some merit , but to keep the good [baby] and get rid of the bad [bathwater] .
Don't put the cart before the horse