This was explained in an io9 interview with the Director, Neill Blomkamp. In short, the prawns are a hive species. When their leaders died, they became rudderless (and not a bit stupid and docile). In the absence of command input and realising that supplies were running short, the ship auto-navigated them to the nearest habitable planet to allow them to disembark and perform repairs. Unfortunately, they encountered us.
As to why it took them 20+ years to gather the fluid to fuel the pod, it seems that it took that long for a potential new leader (Christopher) to fully mature and start making intelligent plans on behalf of the hive:
What is your own back story for these aliens? What's their home planet like? Why did the end up on Earth?
The other thing is that the ship was meant to clip together with other
ships. So there's, like, vast amounts of resources that they're
bringing to the parent planet. And the ship, when the army generals or
the queen of that particular ship died off by some sort of virus or
bacteria that they picked up on some other planet, that killed them
off. And it didn't effect these sort of resilient, hardy sort of drone
workers. Then the technology is usually the thing that they relied on
to save them, but in this case it sort of screwed them because it
brought them to a planet that kind of treated them pretty badly, but
it was the ship that realized that, unless it gets to a life
sustaining planet everything is going to die, which is a cool idea. So
the ship just auto-pilots to the closest one in the Goldilocks band,
and it's our planet and then pulls up and hits the brakes.
Where does this leave Christopher Johnson [an abnormally smart prawn who sparks a bit of a revolution... Not to give too much away]?
I think it's taken 20 years. I think because there is a subconscious hive mind happening, really what they should do is lay one egg that
has a different embryo in it that grows into a Queen or being someone
that dictates direction. But I think in the interim, because they may
have done that, there may be an egg out there with that, but as that
being is growing, I just like the idea that he may have been a lot
more directionless in the beginning. But the hive structure of their
society may just pick one or two that starts to become the leader.
Like the overall structure of his brain may change because the hive
may want that to happen. So he starts having a direction and a goal.
Which is an interesting idea and it's just enough to kick start them
to be able to get to the ship to get back.