I'm looking for the name and author of the story about an alien race that wants to invade Earth, with a lot of weapons and an immense army. It seems the Earth is doomed. The ending, however, is very unexpected: The mother-ship of the aliens land, and a man who walks there happens to put his foot on the ship and flattens it. Now only the reader understands that the aliens are very, very small.
This sounds like part of the Hitchhikers Guide to the Galaxy, by Douglas Adams. An excerpt from Wikipedia:
G'Gugvuntts and Vl'hurgs
Two species which existed in the distant past, a very great distance from the Milky Way galaxy. The G'Gugvuntt were enemies of the Vl'hurgs, and these strange and warlike beings are on the brink of an interstellar war, because of an insult uttered by the G'Gugvuntt leader to the mother of the Vl'hurg leader. [...] the phrase "I seem to be having tremendous difficulty with my lifestyle" (muttered by Arthur Dent to himself, which for some strange reason was carried by a freak wormhole in space back in time to the farthest regions of the universe where the G'Gugvuntts and the Vl'hurgs lived) filled the air over the conference table, [...]
After millennia of battle the surviving G'Gugvuntt and Vl'hurg realised what had actually happened, and joined forces to attack the Milky Way [...] they attacked the first planet they encountered, Earth. Due to a terrible miscalculation of scale the entire battle fleet was swallowed by a small dog. [...]
It features a spacecraft carrying tiny aliens landing on Earth and, after various unfortunate incidents, the aliens get mistaken for insects and wiped out by insecticide.
Things that don't quite match the description: the aliens aren't a warlike invasion fleet, and it's insecticide that finishes them off, not being stepped on. It's otherwise very similar so I suppose it depends how clearly those details are remembered.
As noted in the comments above, this resembles "Pictures Don't Lie" by Katherine MacLean (referenced in this answer and this one) in terms of the alien ship being extremely small and suffering peril from it. What does not match is that it's a peaceful expedition where they have contacted Earth to let us know that they are coming. Also, the implication is not that they've been stepped upon, but rather that they're so small (and their metabolism so fast) that by the time the scientists realize that the ship is sinking in a small puddle in the field, it is likely too late.
You can find a copy at Project Gutenberg.
"A half circle of cliffs around the horizon. A wide muddy lake swarming with swimming things. Huge, strange white foliage all around the ship and incredibly huge pulpy monsters attacking and eating each other on all sides. We almost landed in the lake, right on the soft edge. The mud can't hold the ship's weight, and we're sinking. The engineer says we might be able to blast free, but the tubes are mud-clogged and might blow up the ship. When can you reach us?"
Nathen laughed again harshly, reaching for the mike. "Get them out? There isn't a lake or river within hundreds of miles from here!"
A shiver of unreality went down the Times' spine. Automatically and inanely, he found himself delving in his pocket for a cigarette while he tried to grasp what had happened. "Where are they, then? Why can't we see their spaceship?" Nathen switched the microphone on in a gesture that showed the bitterness of his disappointment.
"We'll need a magnifying glass for that."
Aliens Ate My Homework by Bruce Coville, is another possibility. I even remember some in-book images of the kids sneaker next to the alien's tiny saucer. It was followed up by a few sequels.