In my opinion, WALL-E being broken, then losing his memory, and then getting it back was almost like a brief mini summary of the whole plot of the movie. Earth is destroyed, but now its fixed (can grow life again), but everyone has lost their humanity. And in the end, they gain their humanity back.
We don't know the hardware configuration of Wall-E units, so perhaps there is a seperate long-term memory module stored somewhere else in his unit and the spark triggered a reboot of Wall-E's system that allowed it to reload the memory from this module.
And in the end, that's what the movie is saying about mankind now. The Earth is broken, and needs to be fixed, but we're all losing touch with what made us ALIVE in the first place. So can we REMEMBER that, or not?"
When WALL-E and EVE are flying through the Axiom and we get a medium shot of a bunch of babies who obviously are in school, but the only thing they're being taught is "A is for Axiom, B is for Buy N Large, your best friend." GENIUS. If that's how kids will learn how to read in the future, then our society will never learn to think for itself and do what's actually best for the world and the environment that we live in. Beautifully crafted indeed.
Does anybody notice how much personality the robots in the repair ward have? Now, I've read a lot of reviews on Rotten Tomatoes, and it irks me to see even positive reviews say that that scene was unnecessarily stretched out and pointless to the plot. The BuyNLarge corporation has fixated people on some belief that their social life has to be digital and that robots have to hand them food in a cup. But these "broken robots" have more individuality and heart than any of those humans sitting in lounge chairs have.
It's one of the major messages of the film, breaking out of your routine and actually paying attention to what's going on around you. When we finally see the humans, they are effectively nothing more than robots themselves, flying around on their tracks watching their screens, drinking their food in a cup. It takes Wall-E to practically crash into them in order for them to see the stars, or the pool, or that there's actually a person next to them, and not just on their screen.
It's the same thing when he makes that one robot realize that he can wave with his arm, and the same reason those other robots are considered broken.