According to the Encyclopaedia Britannica, gametophytes are the haploid phase and sporophytes are the diploid phase of plants and algae that undergo the alternation of generations. Gametophytes are similar to gametes in other life forms, but rather than being a single cell that must then form a zygote, gametophytes are living organisms that reproduce themselves asexually.
The alternation of generations allows plants to reproduce both sexually and asexually. Even though both gametophytes and sporophytes contain the genetic material of the plant species in question, these different life phases often look different. Most complex vascular plants spend more time as sporophytes, but mosses are different: the visible part of the plant is actually the gametophyte stage for these species.
Haploid gametophytes only have one copy of each chromosome in each of their cells, which is why this life phase must reproduce asexually. Eventually gametophytes produce gametes which combine to form a diploid zygote. This zygote grows into the sporophyte form. Diploid sporophytes have two copies of each chromosome and are therefore able to undergo meiosis to form haploid spores that grow into gametophytes, bringing the alternation of generations full circle.
Alternation of generations serves an evolutionary function by allowing plant species to combine the chromosomes of individual plants through sexual reproduction while using the haploid phase to eliminate harmful alleles.