It is funny to think of fish sleeping but they do. All animals need to sleep to stay healthy. They sleep when they need to but also it depends on whether they are nocturnal or diurnal. Fish do not have eyelids so they are thought to be resting. They can see when sleeping and can be immediately alert to any dangers. When you see fish being inactive or staying in one spot they are usually resting/sleeping. It is a good idea to shut any lights off to give them the darkness they need. They sleep part of everyday asleep if the conditions are right.
Fish are different in that part of their brain actually shuts down and they lightly rest. They are in constant movement so that they can take oxygen in through their gills and into their bloodstream. It is amazing that some fish actually go into hibernation. When they do this, their metabolic rate slows down. They are not like bears or other mammals. They go into a kind of daze and stop eating. They usually hide at the bottom of the tank or near rocks etc.
Some fish go through a completely detailed event when sleeping. One such fish is called a Parrotfish. They live near reefs that they squeeze into. Once in the there they produce a mucous substance that covers their body in a protective membrane and then they go to sleep. Through research not only has it been found that fish sleep but they can also suffer from sleep deprivation and insomnia just like us. They never reach the REM sleep as we do. I guess if you were a fish, you would not want to be in a deep sleep. You may end up on a hook!