People remember some information for example when learning for an exam, or remember to go to a shop after work etc., but we don't remember usually much other stuff like people passing us, what was the weather some days ago etc. How does the brain know what to remember and what not, how does it filter important information from not important?
The body of work on this topic huge, so I'll just try to mention a few things.
On the cognitive level, one possible answer is salience (also see here for an article specific to the visual system). You can think of this (in a somewhat circular answer) as the thing that makes certain stimuli stand out from others. Salient stimuli capture bottom-up attention. Another possible answer is top-down attention. This is where you actively/deliberately pay attention to something.
In terms of mechanism, we have to think about different types of memory. For example, there are separate long-term and short-term memory systems (among many other distinctions). In general, there are hypothesized gating mechanisms that determine the information that can enter memory. The gating systems are controlled by some signal that says 'store this information' or 'ignore this information'. Different memory networks can have different gating systems.
There's a lot of work looking at neuromodulators as gating signals. Dopamine and acetylcholine are some prominent examples. For example, people have found that dopamine can modulate synaptic plasticity (the strengthening and weakening of connections between neurons, which is thought to be a primary mechanism of long term memory storage). It can also cause cortical remodeling. For just a couple examples, see:
Zhang et al. (2009) Gain in sensitivity and loss in temporal contrast of STDP by dopaminergic modulation at hippocampal synapses.
Bao et al. (2001) Cortical remodelling induced by activity of ventral tegmental dopamine neurons.
Froemke et al. (2007). A synaptic memory trace for cortical receptive field plasticity.
On the behavioral level, stimulating the dopamine system can induce particular forms of learning (which you can think of as a form of memory). For example, if you stimulate the dopamine system, an animal may tend to repeat the behavior that led to the stimulation. A pathological version of this is thought to be what happens during addiction with certain classes of drugs that stimulate the dopamine system (e.g. cocaine, but not lsd).
Interestingly, many of the same mechanisms appear to work across species, from sea slugs to humans). Although,sea slugs can't remember going to a shop after work.
Well I have a theory; I think that when we see at something or some event, our brain processes this information in two separate parts. One of them is composed of the objects on which we are focusing. That part is saved in our memory and we know about it. all other objects from that scene on which we are not focusing our attention, are handled by sub conscious part of our brain. And these are also stored in our memory but we dont know about them.
So memory in brain can be considered as a book with events as its contents. Those events on which we focus are placed in the index of this book. Other events are also stored in the book but are not in the index. When we try to remember something our brain checks the index to fetch the relevant information. So even though majority of stimuli received by brain from our senses are stored in brain, we only perceive to remember those events of which we have created an index ( focused stimuli )