Descartes notices that over the course of his life, he has occasionally accepted some false beliefs, and their falsity has infected other beliefs that he based upon them. What he wants to do is to sort through all his beliefs, set aside all the questionable ones, and to find some beliefs that he can trust as a perfectly secure foundation: some beliefs whose truth is beyond all doubt.
Many of Descartes' beliefs are based on his senses. So he begins by asking whether he should trust his sensory beliefs. Or is it possible to doubt whether these beliefs are true?
Then Descartes remembers that sometimes when he is dreaming, he falsely believes that he's awake. And, reflecting on this, Descartes thinks he can't ever tell whether or not he's dreaming: How can he know that he is really perceiving his hands right now? Maybe it's all just a dream. If it were a dream, everything would seem just the same.
Well maybe, someone would respond, you can tell you're not dreaming by pinching yourself, or seeing that your eyes are open:
...at the moment my eyes are certainly wide awake when I look at this piece of paper; I shake my head and it is not asleep; as I stretch out and feel my hand I do so deliberately, and I know what I am doing. All this would not happen with such distinctness to someone asleep.
To this Descartes responds:
Indeed! As if I did not remember other occasions when I have been tricked by exactly similar thoughts while asleep! As I think about it more carefully, I see plainly that there are never any sure signs by means of which being awake can be distinguished from being asleep.
Here Descartes' point seems to be that for any experience you may have, no matter how much it seems to indicate that you are awake, it would also be possible for you to have that experience while dreaming. So there is no test you can use to determine whether or not you are dreaming. No matter what test you appeal to, the possibility will always remain open that you are merely dreaming that you have performed the test, and that it delivered the results it did. So according to Descartes' argument here, you can't ever tell whether or not you're really awake.
The position Descartes is arguing for here is a lot like the predicament that people inside
The Matrix
are in. Their experiences seem perfectly real to them. They can't tell that it's all just a computer-generated illusion being pumped into their brains. At one point in that movie, the character Morpheus says: "Have you ever had a dream, Neo, that you were so sure was real? What if you were unable to wake from that dream? How would you know the difference between the dream world and the real world?"
Descartes thinks these considerations about dreaming give him reason to doubt all of his sensory beliefs, even ones where there seems to be ample lighting, where the objects seem to be close by, and so on. However, there are a number of beliefs that the dreaming argument leaves unchallenged. When we dream, although the particular beliefs we form ("There's a fire-breathing crocodile chasing me") are often false, the materials for our dream (fire, crocodiles, physical objects) derive from things we experience when waking, and we can still rest assured that some things of those kinds exist. So the dreaming argument leaves unchallenged our belief in general truths about the world (the belief that there are physical objects, that they move in such-and-such ways, etc.) Also, the dreaming argument does not give Descartes reason to doubt his beliefs about mathematics and the like.
At this point Descartes makes two important moves:
If however it were repugnant to the goodness of the Diety to have created me subject to constant deception, it would seem likewise contrary to his goodness to allow me to be occasionally deceived; and yet it is clear that this is permitted.
The argument Descartes is giving here assumes that there is no relevant difference between occasional deception and radical deception, so that if God could permit occasional deception (which, if he exists, he does), he could also permit radical deception. (Later in the Meditations, Descartes will come back to this assumption and he will eventually reject it.)