This ritual goes back to something like 13th century. On this day, people throw beans to get rid of evil spirits and welcome good spirits. By throwing roasted soy beans at Oni (looks like a mask in the photo below and is a representation of an evil), you are getting rid of bad luck out of your house and bringing good luck in at the beginning of spring.
Children, especially, enjoy this ritual and many shrines and temples host bean throwing events for kids. When you throw beans, you would yell "oni wa soto, fuku was chi (bad luck out, good luck in)!"