We analyze transverse oscillations of a coronal loop excited by continuous monoperiodic motions of the loop footpoint at different frequencies in the presence of gravity. Using the MPI-AMRVAC code, we perform three-dimensional numerical magnetohydrodynamic simulations, considering the loop as a magnetic flux tube filled in with denser, hotter, and gravitationally stratified plasma. We show the resonant response of the loop to its external excitation and analyze the development of the Kelvin–Helmholtz instability at different heights. We also study the spatial distribution of plasma heating due to transverse oscillations along the loop. The positions of the maximum heating are in total agreement with those for the intensity of the Kelvin–Helmholtz instability, and correspond to the standing wave antinodes in the resonant cases. The initial temperature configuration and plasma mixing effect appear to play a significant role in plasma heating by transverse footpoint motions. In particular, the development of the Kelvin–Helmholtz instability in a hotter loop results in the enhancement of the mean plasma temperature in the domain.