An ECG machine is a voltmeter (galvanometer). It is used to record the electrical impulses that stimulate the heart. The electrodes record a potential difference. The needle (or pen) of the ECG is deflected a given distance depending on the voltage measured.
The ECG is a plot of voltage on the vertical axis against time on the horizontal axis.
ECG leads are vectors. “The term ‘lead’ in electrocardiography refers to the 12 different vectors along which the heart’s depolarization is measured and recorded.” Wikipedia
The right leg electrode is used for grounding where the voltage is zero.
Dr. Najeeb Lecutures and explains the Basics of the ECG including the concept of an ECG as a voltmeter.