Usually I read a lot of discourage messages about LM7805 (or another linear converter), that it's inefficient, it wastes a lot of energy, it needs heatsink and so on. And the best choose always would be a buck converter.
But, if your circuit needs a small amount of current and the consumption is not a problem, then a linear converter (like LM7805) is a much better solution than a buck converter, because the linear converter in comparison to the buck converter is much easer to integrate in the circuit (all you need is the linear convertor and few capacitors).
Example from datasheet:
For example, we need to convert 12V to 5V for our circuit that draws maximum 25 mA (small PCB with ATtiny85 on board + some additional logic components). I would choose LM78L05 (small package, provides max 100mA), but if you have enough space then LM7805 (TO-220) is even better.
Power dissipation =
\$(V_{in} - V_{out}) \times I_{max} = (12V - 5V) * 0.025A = 0.175W\$
Junction-to-board thermal resistance (SOIC package) = 69.3 °C/W
The temperature = \$69.3 °C/W \times 0.175W + T_{amb} = 12.13°C + 30°C (ambient) = 42.1°C\$
Additionally, I would use a diode on input pin to drop 0.7-1V, which will reduce the power dissipation and the temperature on LM78L05, and ensure that the polarity is correct.