An ECG is performed to evaluate the heart's electrical activity and detect any abnormalities. It helps diagnose various heart conditions, such as arrhythmias (irregular heart rhythms), heart attacks, heart valve problems, and other cardiac disorders.