In yet another absolutely amazing display of nature's prowess, the contents of the egg are wrapped in a perfect, seamless, incredibly strong shell as though by magic! Eggs are objects of art.
It turns out the chicken has little to do with the formation of an egg's shell -- the egg actually grows the shell around itself! It does this using processes that are also seen in bones and seashells.
Around the egg is a membrane, and evenly spaced on the membrane are points where columns of calcite (a form of calcium carbonate) form. These columns stack together side by side to form the shell. According to an incredibly interesting book called "Made to Measure" by Philip Ball:
The calcite is basically floating in solution around the shell, and it deposits on the shell like a forming crystal. The egg grows its own shell!
These links will help you learn more: