Primary bile acids are synthesized in the liver from cholesterol and include cholic acid and chenodeoxycholic acid, while secondary bile acids are formed in the intestine by bacterial action on primary bile acids and include deoxycholic acid and lithocholic acid. These bile acids play a crucial role in the digestion and absorption of dietary fats and fat-soluble vitamins, as well as in regulating cholesterol homeostasis and gut microbiota composition.