A function is part of an answer to a question about why some object or process occurred in a system that evolved through a process of selection. Thus, function refers forward from the object or process, along some chain of causation, to the goal or success. Compare this to the mechanism of the object or process, which looks backward along some chain of causation, explaining how the feature occurred.
A functional characteristic is known as an adaptation, and the research strategy for investigating whether a character is adaptive is known as adaptationism. Although an assumption that a character is functional may be fruitful as a research method, some characteristics of organisms are non-functional, and may simply be emergent phenomena arising as a side effect of functional systems (see Spandrel (biology)). They may also have lost their function over time due to changing conditions, in which case they are said to be vestigial.
The correlation of form (also referred to as structure) and function is one of the central themes in biology. However, knowing the structure of something does not necessarily reveal its function. To illustrate the point, an enzymologist discovering an unknown enzyme would be highly unlikely to identify its function with only structural information. It is also possible for different structures to carry out the same function. Teeth and the gizzard of a bird highlight this point: both grind up food, serving the same function in terms of digestion.
As another example, the function of chlorophyll in a plant is to capture the energy of sunlight for photosynthesis, which contributes to growth and reproduction, and reproduction contributes to evolutionary success. Taking a broader view, all functions have the same end in that they contribute to fitness, though they are each manifested through various proximate mechanisms.
Function is not the same as purpose in the teleological sense. Evolution is a blind process which has no 'goal' for the future. For example, a tree does not grow flowers for any purpose, but does so simply because it has evolved to do so. To say 'a tree grows flowers to attract pollinators' would be incorrect if the 'to' implies purpose. A function describes what something does, not what its 'purpose' is. However, teleological terminology is often used by biologists as a sort of 'short hand' way of describing function, even though they know it is technically incorrect. Laypersons may not understand this distinction, however.
As applied to ecosystems, the word 'function' is has quite a different meaning, and is basically a synonym for processes. Ecosystems do not reproduce and thus cannot be said to have any function in the above sense.
The word may also for non-biological entities, e.g. the ozone layer might be said to have the 'function' of blocking ultraviolet radiation, though this use of the word also does not necessarily imply any teleological cause.