Attracting pollinators (insects etc) to the flower.
Nectar is a sugar, which is the end goal of both cyclic and non-cyclic reactions which occur in all plants, but the main reason is that it attracts pollinators, helping the plant to reproduce
Nectar has no function for the flower itself, other than to attract pollinators.
in the ovary
Eucalypts are excellent nectar plants for bees. Salvation Jane , clover, and lucerne are also good.