Because they poop while they sleep and the eggs get covered in poop.
The only time I ever have to clean my nest boxes is when an egg gets broken.

I used to have a prefab with roosts an inch off the floor. So they weren’t even off the floor with bedding. So of course the girls slept in the nesting boxes, or wherever they could possibly fit (again, pre-fabs)
The eggs were always covered in poop. They had to be washed every day, which was a
pain.
Now I have a much bigger, adequate coop for my girls. The roost are high, coop is large, has lots of ventilation, etc, etc.
I added nesting box doors on the inside so that I could close them, otherwise, the chickens would sleep in them. I don’t always close them now, but if there’s an excess broody needing to be kept off the nests at night, new chicks being integrated (and need to be taught sleeping in the nest boxes is a no no)
Now I don’t have to clean the eggs
at all when I’m cooking.
Only time I clean them is when I’m giving them to a neighbor.
Sorry about this ramble! But I do hate chickens sleeping in the nests... the nests are meant for laying
eggs. Not poop!
Nesting box