Schooling fish are an innate, natural behavior and aquarium owners often place groups into their tanks to achieve an authentic and animated aesthetic. While this is a good strategy, it's essential that aquarium owners understand why schooling fish behave this way - schooling provides protection from predators while finding food, as well as making mating easier and creating larger schools which may fend off predation more effectively.
Another motivation for fish schools to form is reduced water resistance and energy savings when swimming as part of a group. Swimming together reduces resistance because each individual fish follows in step with those ahead, effectively "surfing" on waves left behind from upstream neighbors to save energy by following them along their course. This results in less effort being expended on energy-expending processes by each fish individual in turn, thus saving energy expenditure.
Swarms of fish provide protection for each other by creating an invisible shield from predators; this is particularly effective for small species like Danios and Discus that are more vulnerable than larger fish such as Tunas and Sharks.
Schooling may provide protection to young fish until they have achieved adult coloration and can defend against attacks from larger fish. Schooling also has the potential to improve spawning success by providing a secure environment in which eggs may develop successfully.