This is a common misconception. You don't need a rooster for your hens to lay eggs. A rooster is needed to fertilize the eggs to hatch them into baby chicks, but hens will lay just as many eggs whether there's a rooster around or not.
Some farmers prefer to keep an all-female flock, and urban or suburban homesteaders may not have a choice due to zoning laws that forbid roosters. Sometimes farmers choose not to keep roosters because they can be noisy and aggressive.
When you keep a rooster, you have to be careful about broody hens (who will sit on the eggs, hoping they will hatch), because the eggs will start developing into baby chicks if fertilized. You can use the broody hen to hatch eggs, but this involves some decision-making and supervision so that the eggs you eat aren't the ones she's sitting on.Some farmers prefer to have a rooster, because he does offer significant protection for the flock. He will guard against predators and sound the alert if there is any perceived danger.