In order to keep the flames of the altar burning at all times, the fire had to be fed in the morning and again at night. The obligation to keep the fire burning was a mitzvah independent of the practical need for fire on the altar. The kohanim kept a ner tamid (eternal flame) going separate from the fire needed to burn the sacrifices. (See Talmud Yoma 45a for a discussion of the number of woodpiles on the altar.)
The reason for this mitzvah is similar to the reason for the showbread in Mitzvah #97: God blesses those things utilized by man as part of the Temple service. Fire is representative of the force of nature in human beings, by which we are animated and invigorated. Surely, the energy of people needs God’s blessing so that we will be strengthened to an appropriate degree,
The Sefer HaChinuch gives another reason for the kohanim to continuously feed the fire, based on a statement in Talmud Yoma 21b. It says there that the kohanim placed a man-made flame in addition to fire sent from Heaven by God. That God sends fire for sacrifices He accepts is found throughout Tanach: He did it at the dedication of the Mishkan (Leviticus 9:24), He did it for Gidon and Manoach (Judges chapters 6 and 11, respectively), and He did it for Eliyahu on Mount Carmel (I Kings 18:38). But we also have a principle that God minimizes His miracles to the point at which they could appear “natural.” (See Ramban on Genesis 6:19, Radak on I Samuel 16:2, et al.) This was the case when He split the Red Sea by having the wind blow upon it all night (Exodus 14:21) and it was the case in the Book of Esther, where the Jews’ salvation could be attributed to a series of “coincidences.” Accordingly, excepting cases where an overt miracle would be necessary, God’s “modus operandi” would be to minimize the appearance of a miracle by having the kohanim regularly tend to the fire.
This mitzvah applies to male kohanim when the Temple service is in effect. In the Talmud, it is discussed in the fourth chapter of tractate Yoma, starting on page 45a. It is codified in the Mishneh Torah in the second chapter of Hilchos Tamidin and is #29 of the 248 positive mitzvos in the Rambam’s Sefer HaMitzvos.