Trap statements in shell scripting are used to set up signal handlers that specify how the script should respond to various signals, such as interrupts or errors.