While insects and similar types of organism strived to occupy land, the sea was teaming with life aiming to secure their long term survival. As a consequence of this, reproduction occurred and genetic variation increased. This results in the arrival of fish, who were adapting to live in the largest ecosystem on earth, water.
There are over 20 000 species of fish, all of which have diversified over time to aptly occupy a particular habitat. Since aquatic environments vary greatly in regards to its characteristics, fish diversity also varies greatly.
Factor - Temperature
Depending on season, chronological point in time, depth of water and many other factors, temperature will affect how a fish species would occupy or even exist in an ecosystem. An example is some species being better suited to tropical warm waters while others occupy the polar regions of Earth in its present day
Factor - Saltwater / Freshwater
Fish have diversified to occupy saltwater and freshwater in the best way possible. This is further illustrated in the animal water regulation tutorial page. The main reason for this being a significant factor is the effect that salt has on osmoregulation, thus fish have underwent significant anatomical adaptations to occupy the respective environments
Factor - Biotic Relationships
Other species may represent competition, danger, a source of food or provide a symbiotic relationship. Nonetheless, all species are inevitably a factor, and this is indeed the same case for fish. Check out the producer / consumer relationship page in the freshwater ecology tutorial for an elaboration of this relationship between organisms.
Factor - Other Abiotic Factors
Chemical composition, amount of sunlight and numerous other factors would determine the evolutionary lines of fish from the original ancestors.
Factor - Geological Change
Many years ago the Earth was still very unstable, rapid and extreme geological change would have wiped out adapted organisms and promoted change in the more adaptive organisms.
The most primitive fish are invertebrates, of which some still exist today. These would most likely be the first fish to occupy Earth, having diversified from the primitive crustaceans that occupied the sea beforehand. These primitive and relatively unspecialised organisms would have adapted over a long period of time (millions of years) to take into account the factors above.
Also, as competition increased and available habitats decreased, fish would have had to be more aggressive or more co-operative in their nature to survive in the long term. This has led to species like the shark, which is of phenomenal size and represents danger.
Other species have taken a different approach, adopting chemical defences as a means of survival. Others have adapted to occupy very low altitudes, thus avoiding some of the more competitive habitats closer to the water surface.
All in all, fish, alongside the later developing mammals, would successfully dominate the seas. In the future, mammals would occupy the sea from land, but fish done the opposite; they evolved from sea on to land just like the arthropods intended.