A shelf holds two stacks of items which will not deteriorate due to exposure nor outdoors. Think of a shelf as a 2-tile Stockpile. Their default setting is to contain weapons only. Shelves can be reinstalled as needed and do not block passage. Shelves take the place of any stockpile on its 2 tiles. Like Stockpiles, shelves also have a priority.
The shelf does not have beauty regardless of its quality. However, any items stored within it will remove the ugliness they would otherwise have if left on the ground. The shelf will remove the filth penalty on its occupying tiles but ignores the beauty or lack thereof on the floor underneath.
The 'ugliness reset' of shelves makes them useful for storing raw materials near work spaces without negatively affecting the colonists spending time there. For instance, shelves allow neat storage of Medicine within a hospital, an otherwise -4 to decor if left on the floor. Another example would be storing the materials necessary to make Medicine near a drug lab. Crafting medicine requires three raw materials: cloth, herbal medicine and neutroamine, which anyone might have stored respectively in the tailor's stock and hospital pharmacy. The distance between those stocks and the drug lab will waste large amounts of time that could have been used to craft more medicine instead. Another use of this would be to place food stocks close to your stoves. Your cooks will pick from this, while your haulers restock the shelves as they can.
In Alpha 16, it was known as the Equipment rack and could only store apparel, mortar shells, or weapons.