Compost worms in worm farms and earthworms in compost bins can often be seen gathering in large numbers inside the lid, often trying to escape. This usually happens when it’s about to rain. Before it begins to rain, the air pressure (barometric pressure) in the atmosphere drops, and the worms can sense this, so they climb to the top to avoid drowning. This is a natural survival instinct for when the rain floods their burrows and tunnels in the ground.
If rain is coming, then this is a normal response from worms, and is perfectly natural. If there’s no rain in sight, then this may be an indicator something unpleasant or harmful has been put into the worm farm or compost and may need to be removed. For more information about what materials can and cant be put into compost and worm farms, please see the articles – What Materials Can You Put Into Your Compost Bin and What Not to Compost and The Complete Guide to Worm Farming, Vermicomposting Made Easy.