What are Ferns?
The first plants that had leaves evolved from plants that were more like moss about 360 million years ago. We call these early plants with leaves "ferns". Like moss, most ferns grow in places where there is plenty of water: usually near the banks of streams. But eventually some ferns were able to figure out how to live in dry places too.
Many ferns had underground stems, like mushrooms. They also had roots like the roots of trees or flowers, so they could pull food in from the dirt through their roots. Having leaves gave the ferns a much broader surface to collect sunlight for photosynthesis. This gave the ferns a big advantage over earlier plants like moss.
Because ferns evolved in a time when the only plants growing on land were moss and fungi like mushrooms, many ferns developed relationships with fungi. Some ferns can't live without their companion fungus that protects them and gets them food. Most of these fungi live on the roots of the ferns.
After flowering plants evolved, about 100 million years ago, they were more successful than ferns and most of the places where ferns and cycads had grown were taken over by the flowering plants. Perhaps in response, ferns evolved quickly into new forms, becoming more like modern ferns. Today ferns grow mainly in places where flowering plants can't grow because it is too wet or too shady or the dirt is too acidic, or there isn't enough dirt (like in cracks in rocks). Some ferns have evolved to live on the flowering plants themselves, growing right on the trunks of living trees. Some ferns evolved into cycads.
Bibliography and further reading: