"The first eggs appeared long before the first chickens. They didn't contain chickens, of course. But they contained the animals whose descendants would eventually become chickens.
The very first "eggs" were produced by ancient invertebrates that broadcast their gametes into the open ocean where sperm and egg fused to become a zygote (fertilized egg). Later evolution produced species that secreted a protective shell around the zygote, and this little capsule, as simple as it was, could still be considered an egg.
For the sake of argument, though, let's consider only the *amniotic*egg, which is unique to vertebrates (such as chickens). It contains a complex system of internal membranes that not only hold fluid to keep the embryo moist and cushioned, but also to collect its waste and hold its nourishment (yolk). The mammalian placental system is nothing more than a modified amniotic egg that is retained internally, lacks a shell, and has modified membranes. You can find a diagram and more information about the amniotic egg here:
Introduction to the Amniota
The very first organisms that produced an amniotic egg were terrestrial, reptile-like animals that didn't have feathers. But one branch of this lineage did evolve and give rise to the feathered reptiles we now know as birds. This change resulted from various forces, including natural selection, genetic drift (evolutionary change due to random chance and small population size) and chance mutations that proved beneficial to the individuals that inherited them. The first, ancestral "birds" were pretty much small, feathered dinosaurs. They laid amniotic eggs, but they weren't chickens. Some of their descendants evolved into today's chickens.
So if you want to take the "chicken or egg" question literally, then the egg evolved long before there were any chickens. It was only much later that the first "chicken" popped out of that amniotic egg that had given rise to many other species before."
Source:
Evolution: evolution of the chicken, ucmp berkeley, amniotic egg
Debate Over.