When an organism is sessile, or slow moving it might be very hard for that organism to find food, shelter and a reproductive mate.
One of many solutions to the problem of finding a mate is hermaphroditism.
When an organism is hermaphroditic it means that it has the reproductive organs of both sexes and that it is able to self-fertilize.
This solution, although sometimes very useful, if used all the time can lead to inbreeding and have negative effects on the genetic diversity of the population. Therefore, hermaphroditic organisms self-fertilize only in cases where there is no available mate to be found.