Now, on one hand, he must do so. He has no other way to tell Harry what he needs to know in time. On the other hand, his memories are vastly in excess of what is needed. (The first thing I noted was the info-dumping element.) Given that superfluous scene of his literally demanding that Harry never, ever, ever know -- exactly what he's revealing to him now, one would think a powerful motive was needed.
I could think of several reasons the first time. He's dying and errs on the side of too much rather than too little, because he can't try again later. He's dying, and his control is not of the finest, and with Lily Evans's son in front of him his memories naturally list to Lily and Harry. Or he discovers after all (perhaps after the year of suffering as the man who murdered Dumbledore) he doesn't want to have his memory be nothing but infamy.
And another one came to me this time: he needs to give Harry enough background to convince him that he's telling the truth. He may not know that Harry knows memories can be tampered with, but he can hope that revealing as much as he did will convince him that he's sincere.
The problem is that we are literally in his thoughts, and we don't get his motives. The last memory could have been of his seeing Harry walking toward him and his desperate resolve to get the info across. With what ever combination of motives he had, since all of the above are compatible.