Nectar is a sugar-rich liquid produced by special glands on a plant. These glands are usually associated with the flowers - but not always. Floral nectaries are usually found at the base of the petals so that a visiting insect picks up or deposits pollen whilst collecting the nectar; thus, 'helping' the plant to reproduce / set seed. Common pollinators are bees, bumblebees, wasps, moths, butterflies and hummingbirds; less common pollinators are flies, ants, possums and bats.
The sugars found in nectar are sucrose (a disaacharide - the same sugar used for sweetening drinks, cake making etc), glucose and fructose (both monosaccharides - fructose is sometimes called fruit sugar). Other organic compounds may be present, but usually in much smaller amounts such as various amino acids and sometimes VOC's (volatile organic compounds - these may help attract pollinators). Insect pollinated flowers are termed entomophilous.
The concentration of the sugar in the nectar of a flower is quite variable - depending on the plant species and the nature of the pollinator. The more sugar that there is in the nectar, the more viscous is the nectar. If the nectar is too viscous then this can present a problem to an insect, such as a butterfly - that draws up nectar through a 'long' tube-like structure, a proboscis. The nectar is drawn up the proboscis when a suction pressure is generated through the contraction of a set of muscles - the cibarial muscles or cibarial pump.
No animal 'wants' to spend too long in accessing food / nectar as it is visible and vulnerable to predators. Bees and bumblebees use a different mechanism to butterflies, they take in nectar using a tongue. Flowers pollinated by bees tend to have a more viscous / energy-rich nectar (about 35% sugar), whereas butterfly pollinated flowers generally produce a 'weaker' nectar - which is about 20 / 25% sugar.
Nectaries can be found elsewhere on a plant - on leaves, leaf stalks (petioles), stems and fruits; these are extra-floral nectaries. They too produce a sugary nectar but it has nothing to do with pollination. Extra-floral nectaries are thought to be part of a plant's defence system. The nectar attracts predatory insects, which make use of the nectar but also function as 'bodyguards'.
Some carnivorous plants have extra-floral nectaries to attract insect prey, which when digested provide a valuable source of nitrogen compounds for the plant. For example, certain pitcher plants have nectaries around the rim of the pitcher - if an insect 'loses its footing', it then falls into the liquid within the pitcher, drowns and is slowly digested.