What is the primary function of the endocrine system?

Controls everything. The endocrine system is composed of "ductless" glands that produce various hormones. Thyroid hormone controls the bodies metabolism, adrenal hormone is involved with stress hormones, pituitary hormones control other hormones of the body including reproductive hormones. Insulin is a hormone that controls blood sugar. There are thousands of hormones in the body that control various systems.