AWS Lambda runs your code in response to events, such as data arriving from IoT devices. It allows you to automate tasks like data processing and triggering alerts without managing servers, making it a versatile tool in your IoT architecture.