In 2805, Earth is abandoned and largely contaminated with garbage, with its people evacuating with megacorporation Buy-N-Large's starliners. In place, BnL leaves WALL-E compactors to clean up, however only one survives and gains sentience. One day, WALL-E discovers a healthy seedling. Later, a spaceship deploys an EVE probe from the starliner Axiom to scan Earth. WALL-E is infatuated with the initially hostile EVE, who gradually befriends him. When WALL-E brings EVE to his trailer and shows her the plant, she standbys and encapsulates the plant. WALL-E, confused, unsuccessfully tries to reactivate her. The ship then collects EVE, with WALL-E clinging on, and travels to the nebula-concealed Axiom.
Onboard, the ship's passengers have become obese due to microgravity and reliance on automated crew and hoverchairs. The ship's current captain, McCrea, leaves primary controls under the robotic autopilot, AUTO. WALL-E follows EVE to the captain's bridge, where McCrea learns that by placing the plant in the Holo-Detector to verify, the Axiom will hyperjump back to Earth so the passengers can recolonize it. However, AUTO orders McCrea's robotic assistant GO-4 to steal the plant as part of his own no-return directive A113, which was issued to BnL autopilots after the corporation concluded in 2110 that the planet could not be saved.
EVE is considered faulty and taken to Diagnostics, along with WALL-E for cleaning, mistaking the procedure as torture and accidentally freeing malfunctioning robots. Sentinels target the duo, while EVE evades them and takes WALL-E an escape pod to send him home for safety. However, GO-4 is revealed to have the plant, placing it inside a self-destruct pod, jettisoning it as WALL-E enters. WALL-E escapes with the plant before self-destruction and uses a fire extinguisher to propel himself, where he and EVE reconcile and dance in space.
When the plant is brought to the captain, EVE's recordings of Earth are analyzed and McCrea concludes that they must restore it. However, AUTO reveals his directive and mutinies, severely tasering WALL-E and shutting down EVE but destroying GO-4 accidentally. McCrea activates the ship's Holo-Detector, but AUTO crushes WALL-E by closing it before McCrea, forced to walk, disables him and EVE activates the hyperjump.
Having arrived back on Earth, EVE repairs and reactivates him, with his memory erased and defaulted. Heartbroken, EVE gives WALL-E an electrical farewell kiss, restoring his memory and personality. WALL-E and EVE reunite as the humans and robots of the Axiom restore Earth and its environment.

Question: Why is Wall-E and those like him left behind when the earth is evacuated?
Answer: To clean the trash up.
Alternative answer: They are used as compactors to clean up.