Manufacturers conduct extensive stability testing to determine how long a product maintains its intended potency and safety. This involves storing the product under various conditions and testing it at different intervals. The expiry date is then set based on the results of these tests, often with a safety margin.