Today, the term lantern is used to describe many types of portable lighting, but lanterns originated as a protective enclosure for a light source - usually a candle - to make it easier to carry and hang up, and more practical outdoors or in drafty interiors such as passages and staircases where unguarded candles were more likely to be blown out by gusts of air - not just from wind but even opening a door.
Lanterns were usually made from a metal frame, commonly with a hook or hoop of metal on top. Though some lanterns had up to eight sides, five or six was not uncommon but four was the standard, these would be made of some translucent material, now usually glass or plastic but formerly thin sheets of animal horn or tinplate punched with holes or, more ornately, in decorative patterns; though some antique lanterns have only a metal grid, clearly indicating their function was that outlined below.
Though primarily used to prevent the light from being extinguished, their equally important function was to reduce the risk of fire should a spark leap from the flame or the light be dropped. This was especially important below deck on ships, not only because of the common presence of gunpowder but because fire in a warehouse on land would cost money but fire aboard a ship was far more likely to cost lives too.
Use of unguarded lights was taken so seriously that obligatory use of lanterns below decks was even written into one of the few known remaining examples of pirate code - and it is reasonable to assume, given the severity of the punishment and the possible consequences of dropping a naked flame in confined spaces filled with flammable materials, that the use of lanterns was very widely considered an essential safety measure. Note that the term used was "lanthorn", which perhaps has its etymology in the above mentioned use of thinned animal horn as the sheet material in the lantern (article VI of Captain John Phillips's articles).