Even if we assume a virus is a non-living thing, they reproduce by taking over a living thing, a cell. Mutations occur when a copy of the virus produced by the cell isn't an exact copy. The copying requires energy provided by the cell, but the errors in the copying require no energy, per se, so the law of thermodynamics is not broken.