If you put a small block of wood on a table you can slide it around easily, but if you put a heavy weight on top of the block you will need to apply a much bigger force to move the block. This is a simple example of friction. The bigger the force holding the block against the table, the bigger the force needed to make it slide.
Sand consists of lots of small, hard grains of rock that can slide over each other.
If the forces pushing the sand grains together are small, then the grains slide easily over each other. This is the case for the dry sand in the bucket. The sand grains are only pushed together by the weight of any grains above them, so when you tip the bucket upside-down they slide easily until they form a conical pile. The angle of the sides of the pile is sometimes known as the angle of repose. When the sand is damp, each grain is coated with a thin film of water, which tends to collect at the points where the grains touch.