A fern will require some direct sunlight, but not too much. Ferns also prefer climates that are more or less constant. A fern will usually not live through a frost.
Ferns have even more specific conditions when it comes to reproducing. For example, a fern may live for a while in a fairly hostile environment, but will most likely not be able to reproduce there.
Ferns will only grow naturally where conditions suit the survival of both the plants themselves, and the intermediate gametophytes. It is commonly accepted that the strength of the gametophyte alone will determine survival of the fern.
Ferns have evolved to suit their environment.
While some ferns are able to tolerate drought and heat, others will only thrive in the densest of rain forests.
For a fern to grow properly in a garden, the garden and its surroundings must be very similar, nearly identical, to the environment it evolved in.
For example, a tree fern, found mostly in rain forest climates, will not live in a garden that mimics a desert.