Why was It Invented?

I often wonder why it was invented. I mean what need where they trying to satisfy when they invented that? Sometimes an invention is the result of an accident like x-ray photography.