There is much remaining to be understood about human memory. But significant aspects of memory can be understood based on the better understood memory used in devices we call computers. So while what follows involves a theory of memory, the presentation is more as a comparison with magnetic memory used in computers. Current computer memory utilized the orientation of small magnetic crystals, a mechanism certainly different than that used by most animals on earth. (There may be very limited use of magnet orientations by birds for identification of direction.) Still, the similarities can be useful for understanding human memory.
Memory in animals probably evolved as a mechanism to retain information gathered by sense organs. Very simple organisms detect light, sometimes to move into preferred locations. There would be survival value in storing previous light intensity to determine by comparison whether movement brought the organism to a location of greater or lesser light. On the primitive earth, organisms using chlorophyl to grow food would be best located in regions of light while excessive ultraviolet light could damage an organism. Memory could be similarly useful for retaining information from other sense organs as well.
Unlike modern computer operating systems, animals have not utilized what is called protected memory where preservation is assured by preventing subsequent changes. Perhaps because animals typically needed more memory storage than they possessed, old memories were typically overwritten by newer observations. The more valuable of short term memories could be preserved by several different mechanisms, the most likely by copying to other memory locations where over writing was less frequent. Human senses produce vastly more information than the human brain can store. Therefore it is appropriate for most to be ignored and promptly overwritten. Only when we associate a small portion of sensual input with something of significance is there an effort to store it for possible recall.
Recall may use a mechanism vaguely similar to the links used in the internet code language, html. For example when this author creates a web page, he first records the textual content then later reviews the content and inserts additional computer code which links particular content to associated content elsewhere. The revised content is then re-saved, typically in another location in the magnetic medium which stores the memory. The location of the original content is marked available for further use. However it typically is not immediately overwritten so that the original version can often be recalled some time later (using certain utility programs). If more links are added to a content and the content saved after each new link, a number of sequential copies may exist in the memory device. In a similar manner, the more a human memory is recalled, the more links or associations are created to it. In a device such as a brain where any memory can be overwritten, multiple copies would make preservation of the memory more likely. (Again, the mechanism of human memory is not well understood, and probably is not identical to computer memory. The intent is to develop understanding using similarities.)
It is unlikely that any of the senses provide continuous information. Much as video cameras transmit a sequence of still images, eyes and other sense organs do likewise. We are just beginning to understand the signal processing used by animals to detect motion and other changes by comparing one image to the next. Computers monitoring security cameras can, as an example, trigger recording of events when motion is detected. It is likely that there is an accompanying process much like morphing used in video compression where key visual images are stored then intervening changes reconstructed by interpolation as desired. (This allows computer programmers to display more rapid and detailed images than the computer could otherwise recall, process, and transmit.) Thus intermittent information that contains differences is comprehended as a viewing of steady motion or change.
In a similar process, human memory can also extrapolate by imagining what occurred either before of after events which were actually observed. As in any extrapolation, this is a process where deviations from reality are more likely than in interpolation. For example, if a group of people hear at yelled "DON'T PUSH ME," they are likely to imagine some sort of push might have occurred. But because each person will imagine based on their memories of past experiences, it is likely that details of any push will be different. Computer morphing which extrapolates from memory is also more likely to contain impossibilities such as a person walking up stairs emerging from below the bottom step or continuing into the air above the top landing. As can computers, the human mind can integrate understanding of the laws of physics to avoid such unreasonable interpretations. The processes of interpolation and extrapolation help humans understand sequence of observations when only a portion of the events are actually witnessed. Because the processes are a part of normal thought processes, humans often are unable to distinguish what the actually observed from what their minds imagined in interpolation or extrapolation.
The value of dreams is even less clear. But rarely, if ever, does a mechanism develop which did not have value to the organisms. So likely dreams have significant value even if that is not presently understood. Three years ago this author proposed a possible model for understanding the value of sleep. Computer programs often are constructed in small sections, each of which performs a small function. these may be sequentially called upon to complete a more complex task. Information may be temporarily stored in available memory for later use. Records are maintained of the locations of all information and portions of programs. But over time the chain of references gets long, intertwined, and disjointed, slowing computer processes. This was traditionally overcome by rebooting the computer or relaunching the program. Modern operating systems may do periodic maintenance, clearing of log files, and .... Dreams might help this process by partially recalling past memories and this allowing them to be refreshed and re-saved in memory. But they can sometimes introduce inaccuracies into memory. A former student, now a parent with child in school once recalled having struck his teacher causing a bloody, broken nose. When asked about disciplinary consequences, he said their had been NONE! At the time described in the incident, disciplinary punishment for such an offense would have been rapid and harsh. Assaulting a teacher for any reason would have resulted in immediate suspension from school and further action by the police. The former students memory was obvious false, perhaps the memory of a dream which had never been real. While dreaming may have positive value for the success of an individual, the occurrence of false memories may be common although seldom noticed.
Much of the above involves speculation. Much remains to be known about memory. It is important to distinguish which is observation and which is interpretation. The first, sometimes called scientific fact, is typically very reliable. Interpretation, sometimes called theory, is valuable and often essential to human understanding. But the history of science reveals that interpretations often require revision. Keep you mind sharp by pondering alternative explanations. Still, it is probably unwise to reject an interpretation outright unless you have a better explanation available!