The breed of the chicken determines eggshell color. More often than not, chickens with lighter earlobes also have white feathers and produce white eggs. Those with colored feathers and darker earlobes will likely produce colored eggs.
Why are some eggs speckled?
Same thing with birds; it’s mostly genetic. Birds that don’t have white eggs often put their nests on the ground and the eggs have speckles on them, little brown spots or other colored dots. This is more than likely for camouflage.