The ferret, closely related to the polecat, originated in Europe. They are descended from the European polecat (Mustela putorius).
Ferrets were officially (genetically considered) domesticated approximate 2,500 years ago.
Throughout history where evidence of ferrets appeared, their purpose was primarily for hunting rabbits, and less commonly for other rodents and moles.
They only became common as pets in the US less than 100 years ago. Prior to that, ferrets were introduced to the US in the 17th century, and used in the west for keeping down the rodent population on grain stores.