Joule’s law of heating states that when a current ‘i' passes through a conductor of resistance ‘r’ for time ‘t’ then the heat developed in the conductor is equal to the product of the square of the current, the resistance and time.
H = i2rt
The reason behind the heat produced is the collision of the free electrons with the lattice ions or atoms while accelerating in presence of the external electric field.