From the harsh, unforgiving landscape of Camp Green Lake, to the beautiful backdrop of Miss Katherine's town, to the stinky, life-saving meadow at the top of the mountain, the physical world of nature plays a big part in the story's events. Over and over in Holes, nature both reflects and comments on the moral and emotional state of the characters. Deep, right? But be careful: what people see in the natural world is just the surface; it's important, the book tells us, to look beyond surfaces. Life, as reflected in the natural world, is often messy and smelly, and what you see isn't always what you get.
In the world of Holes, nature is always deceiving on its surface: you can never trust appearances.
Sam and his onions are closely associated with the natural world. So when the townspeople murder Sam, this is kind of a rejection of the natural world. This is why nature abandons the town – i.e. it stops raining – in the aftermath of the murder.