They do it to make you spend more time browsing. Shoppers typically get the same stuff every time they get groceries. Over time people learn the layout of their local store and develop efficient patterns to move through it and get everything they want. When the store shuffles everything around they force shoppers to wander around the store and to look at all the shelves carefully for the stuff they actually want. Some percentage of them end up finding new things to buy and spend more money.
I can’t guess what individual people will do but, as a group, shoppers end up spending more this way. Supermarkets and grocery stores typically sell many things besides food; toys, magazines, beauty products, etc.
The store also doesn’t need you to eat all the food you buy. If you throw out a bunch of food, as many people frequently do, the store still gets paid for all of it.