Your heart generates impulses and beats on its own. This beat is then modified by different regulatory systems in your body. Their job is to respond to external stressors by speeding up or slowing down the heart rate in order to to help keep your body’s internal environment stable.
The signals sent by these regulatory systems are constantly playing tug-of-war with your heartbeat, which is what makes it variable.