Eggs or zygotes are the products of sexual reproduction. They are formed when a sperm fertilizes an ovum. Not all animals lay fertilized eggs. Many animals have external fertilization. They often release sperms and ova into the environment and fertilization occur outside of the body. Many aquatic animals simply release thousands, even millions of eggs into the water to allow them to be fertilized by sperms that are released at the same time.
Frogs also practice external fertilization. The female releases eggs and the males fertilize them while they are released. Salamanders evolved internal fertilization. The female picks up a packet of sperm and the sperms then fertilize the eggs inside the body. Some fish, for example sharks, also practice internal fertilization. Many other groups of animals, including insects, also practice internal fertilization. Therefore it is nearly impossible to find out when internal fertilization first evolved since it has apparently evolved many, many times in different kinds of animals independently.
The common ancestor of reptiles birds, and mammals, which was a primitive reptile, evolved internal fertilization since all descendants of that common ancestor have internal fertilization. The first reptile is dated to about 315 million years ago, and the earliest amphibians are dated to about 350 million years ago. Therefore internal fertilization probably evolved between 315 and 350 million years ago in vertebrates. It probably evolved earlier in insects and other arthropods, as they evolved to be land animals around 420 million years ago, long before vertebrates did the same.