Cities may establish a board of health and prescribe its powers and duties; pass all ordinances and make all regulations necessary to preserve the public health; prevent the introduction of contagious diseases into the city; and make quarantine laws for that purpose and enforce the same within the city.