The law of conservation of energy states that the total energy in an isolated system does not change. It may change form, for example mechanical energy may get converted to thermal energy, gravitational potential energy may get converted to mechanical energy and the alike, but the total energy in the system remains constant.
Friction is a resistive force to motion. When two bodies move against each other some of the kinetic energy is converted to heat energy due to friction. This reduces the total kinetic energy in the system. If a body was moving up a slope, in the absence of friction all the kinetic energy of the body would have been converted to gravitational potential energy but due to friction a part of it gets converted to heat. This reduces the total gravitational potential energy acquired by the body. Mechanical energy is reduced due to friction and converted to heat. This is the reason why there is an increase in temperature in objects that move against each other.
The role of friction in a closed system is to convert a part of the total energy to heat.