Moses Pbuh was born on a year that the Pharoah killed the newborn males, Allah Almighty inspired to his mother and says: (And We inspired to the mother of Moses, “Suckle him; but when you fear for him, cast him into the river and do not fear and do not grieve. Indeed, We will return him to you and will make him [one] of the messengers) [Al-Qasas 28: 7]
This was so to save Moses from the Pharoah who would have killed him.