The question of how we know what we know is a complicated one, with an entire branch of philosophy, epistemology, devoted to it. The biggest problem is that there's almost nothing that we can know for certain. All of our information about the world comes to us through our senses, and we have no way of knowing if what are senses tell us reflects anything "out there," whether there is an objectively real world that is reflected in our sense data or if everything we experience is an illusion.
Descartes illustrated the problem by positing a deceptive demon who fed him sights, sounds, smells etc. to simulate a reality that doesn't really exist. Since 1999 The Matrix has been the go-to analogy. The world experienced by those in the Matrix is a perfect illusion. How can any of us know if we are in the Matrix? And, since we may be in the Matrix, how can we know what is real? Or even if there is anything at all?
Descartes found one thing we can be certain of: we each can be certain of our own existence. If we experience things and think about things, there must be something doing the experiencing and thinking. It may be something completely unlike what we think ourselves to be, something not remotely human, but there has to be something that is doing the thinking. Descartes famously summed up this single ontological certainty as, "Cogito, ergo sum," "I think, therefore I am."
But what now? If all we can be certain of is our individual existence, how do we determine what, if any, of what we experience is real? And are we justified in making any and all claims about reality, given that all claims are equally unprovable?