The phrase has been used in this sense since the 1700s, so it has quite a long history. Presumably the idea behind it was the fact that - whilst pregnant - the woman concerned was "on her way" to adding to her family.
Pregnant, as in "Mary's in the family way again". This euphemistic expression dates from the late 1700s.
The meaning is similar to "a bun in the oven".