I'm going to explain the rearing of young with reference to cichlids, a family of fish found primarily in fresh waters.
Cichlids care for their young. I am going to explain how this might have developed.
The ancestral cichlid, in common with many fish, would lay its eggs and then leave them. If a cichlid had a tendency to remain in association with its eggs, in the general vicinity, this would reduce the numbers of small predators coming by to feed on the eggs. Therefore, more would be likely to hatch and become young fish. This trait became common among cichlids. Later, a cichlid with a lesser tendency to eat its own young, as most fish would, was also at a selective advantage, as more of its young would survive. So this trait also spread, and strengthened through positive selection. Later still, certain cichlids began to perform other activities around the eggs, by stages, such as 'hovering' above them to fan water over them and eating the infertile eggs, leaving more room for the remainder and discouraging the development of pathogens. Also, some fry would emerge with a tendency to stay in association with their parent, as there would be less predators around. All these traits spread. Those parent cichlids which, when surrounded by their fry, moved slowly and brought them towards food supplies would also benefit their young, and so became more common.
So now most cichlids care for the eggs and fry, leading the latter to food supplies. Certain cichlid varieties have developed which care for their offspring using special techniques, for example through exuding a nutritious substance from beneath their scales for the young to eat, through caring for the eggs or fry within their mouths, communal parenting, etc.