Beak trimming or treatment is done when the birds are about a day old to prevent laying hens from harming one another. Some people call it "debeaking" which might make you think that the whole beak is removed when that's not the case at all.
The proper procedure is to remove just the tip of the beak, which is done with an infra-red beam in most cases when the birds are very young. (Picture the hook on the end of an eagle's beak).
In cage-free housing systems, hens are kept in larger groups and aggression between hens that compete to be at the top of the hierarchy (or pecking order – the term started with chickens!) can be a problem.
Chickens quickly determine who are the "top hens" the "middle hens" and the "bottom hens" in the pecking order. This dominance level helps to determine which get preferential access to feed and water.
Beak trimming helps prevents injury to other birds if they peck each other.