The primary function of the Z line is to anchor the thin filaments (actin) and to demarcate the boundaries of each sarcomere. This anchoring facilitates the transmission of the contractile force generated by the sliding of actin and myosin filaments. Additionally, the Z line helps maintain the alignment of sarcomeres, ensuring coordinated muscle contraction.