The primary function of the myenteric plexus is to regulate the peristalsis and coordination of muscle contractions in the gastrointestinal tract. It ensures the smooth passage of food and waste through the digestive system by modulating the strength and frequency of muscle contractions.