In the early Buddhist suttas, the word 'sati' translated as 'mindfulness' literally means 'memory' and practically means 'recollection' or 'bringing to mind' or 'keeping in mind'. Thus the early Buddhists suttas say:
And what is the faculty of mindfulness? There is the case where a
monk, a disciple of the noble ones, is mindful, highly meticulous,
remembering & able to call to mind even things that were done & said
long ago. SN 48.10
When one has heard the Dhamma from such bhikkhus... dwelling thus withdrawn, one recollects that Dhamma and thinks it over. Whenever, bhikkhus, a bhikkhu dwelling thus withdrawn recollects that Dhamma and thinks it over, on that occasion the enlightenment factor of mindfulness is aroused by the bhikkhu; on that occasion the bhikkhu develops the enlightenment factor of mindfulness; on that occasion the enlightenment factor of mindfulness comes to fulfilment by development in the bhikkhu. SN 46.3
One is mindful to abandon wrong view & to enter & remain in right view: This is one's right mindfulness.
One is mindful to abandon wrong resolve & to enter & remain in right resolve: This is one's right mindfulness.
One is mindful to abandon wrong speech & to enter & remain in right speech: This is one's right mindfulness.
One is mindful to abandon wrong action & to enter & remain in right action: This is one's right mindfulness.
One is mindful to abandon wrong livelihood & to enter & remain in right livelihood: This is one's right mindfulness.
Thus these three qualities — right view, right effort & right mindfulness — run & circle around right view, right resolve, right speech, right action... right livelihood.
MN 117
Thus the role of mindfulness is to keep out unskilful dhammas and to remain in skilful dhammas, as further explained in AN 7.67:
Just as a citadel has a gatekeeper who is astute, competent and
intelligent, who keeps strangers out and lets known people in, in
the same way a noble disciple is mindful. They have utmost mindfulness
and alertness, and can remember and recall what was said and done long
ago. A noble disciple with mindfulness as their gatekeeper gives up
the unskillful and develops the skillful, they give up the
blameworthy and develop the blameless, and they keep themselves
pure. This is the sixth good quality they have.
The later Abhidhamma Pitaka maintains the above correct explanation of mindfulness, where the Vibhanga says:
Therein what is controlling faculty of mindfulness? That which is
mindfulness, constant mindfulness, recollection, mindfulness, act of
remembering, bearing in mind, non-superficiality, non-forgetfulness,
mindfulness, controlling faculty of mindfulness, power of mindfulness,
right mindfulness. This is called controlling faculty of mindfulness.
The next influential text is the 5th century Visuddhimagga. Having a quick browse, it includes:
And as Pátimokkha restraint is undertaken out of faith, so restraint of the sense faculties should be undertaken with mindfulness. For that is accomplished by mindfulness, because when
the sense faculties’ functions are founded on mindfulness, there is
no liability to invasion by covetousness and the rest. So,
recollecting the Fire Discourse, which begins thus, “Better, bhikkhus, the extirpation of the eye faculty by a red-hot burning
blazing glowing iron spike than the apprehension of signs in the
particulars of visible objects cognizable by the eye” (S IV 168), this
[restraint] should be properly undertaken by preventing with
unremitting mindfulness any apprehension, in the objective fields
consisting of visible data, etc., of any signs, etc., likely to
encourage covetousness, etc., to invade consciousness occurring in
connection with the eye door, and so on.
Recourse to mindfulness both in the accepting and the use of medicine
is proper; but while this is so, though there is an offence for one
who uses it without mindfulness after mindful acceptance, there is no
offence for one who is mindful in using after accepting without
mindfulness.
With mindfulness of death, thinking, “I have got to die,” he gives up improper
search (see S II 194; M-a I 115), and with a growing sense of urgency he comes to
live without attachment. When his mind is familiar with the perception of foulness,
then even divine objects do not tempt his mind to greed.
Strong mindfulness, however, is needed in all instances; for mindfulness
protects the mind from lapsing into agitation through faith, energy and
understanding, which favour agitation, and from lapsing into idleness through
concentration, which favours idleness.
Herein, mindfulness has the characteristic of remembering. Its function is not to
forget. It is manifested as guarding. Full awareness [sampajanna; situational wisdom] has the characteristic of non-confusion. Its function is to investigate (judge). It is manifested as scrutiny
Mindfulness (sati) itself is recollection (anussati) because it arises again and
again; or alternatively, the mindfulness (sati) that is proper (anurúpa) for a
clansman gone forth out of faith, since it occurs only in those instances where it
should occur, is “recollection” (anussati).
The recollection arisen inspired by the Enlightened One is the recollection of
the Buddha. This is a term for mindfulness with the Enlightened One’s special
qualities as its object.
The recollection arisen inspired by the Law is the recollection of the Dhamma. This is a term for mindfulness with the special qualities of the Law’s being well
proclaimed, etc., as its object
In summary, the above examples from the Visuddhimagga show a non-departure from the original meaning of mindfulness, namely, that mindfulness acts to remember what is virtuous & what are the Path Factors and to remember to keep those Path Factors in the mind rather than to allow the mind to stray into pre-occupation with non-Path mental states. In short, as simply explained in MN 117, the primary role of mindfulness is to keep Right View in the mind because it is Right View that defines all of the other Path Factors. In summary, the most single role of Right Mindfulness is to remember to keep Right View in the mind.
If we continue to browse the Visuddhimagga, we find it starts to depart into the false Hindu Yoga explanations of mindfulness which cloud modern ideas about mindfulness & cause an inability to attain Stream-Entry. The Visuddhimagga says:
The mindfulness arisen inspired by breathing (ánápána) is mindfulness
of breathing. This is a term for mindfulness that has as its object
the sign of inbreaths and out-breaths.
Herein, developed means aroused or increased, concentration through
mindfulness of breathing (lit. “breathing-mindfulness concentration”)
is either concentration associated with mindfulness that discerns
breathing, or it is concentration on mindfulness of breathing.
Practiced much: practiced again and again
Gone to the forest … or to an empty place: this signifies that he has
found an abode favourable to the development of concentration through
mindfulness of breathing. For this bhikkhu’s mind has long been
dissipated among visible data, etc., as its object, and it does not
want to mount the object of concentration
through-mindfulness-of-breathing; it runs off the track like a chariot
harnessed to a wild ox.... when a bhikkhu wants to tame his own mind
which has long been spoilt by being reared on visible data... tie it
up there to the post of in-breaths and out-breaths with the rope of
mindfulness.... being unable to break the rope of mindfulness and
get away, it sits down, lies down, by that object under the influence
of access and absorption.... Hence the Ancients said:
Just as a man who tames a calf
Would tie it to a post, so here
Should his own mind by mindfulness
Be firmly to the object tied.
Therefore above, instead of the primary role of mindfulness being keeping Right View in the mind, the role of mindfulness is transformed into remembering to watch a physical object. The fatal deadly problem with this is, instead of Right Mindfulness rightly acting to abandon craving (which is Right View), a wrong mindfulness is developed which craves to tie the mind to a physical meditation object. This wrong mindfulness prevents Stream-Entry because the mind does not 'let go'. The early suttas (such as SN 48.10 and the end of MN 118) literally say the practice of Right Mindfulness matures as letting go (vossagga), which is the cause of Right Concentration (jhana).
From this nonsense, we get the nonsensical translations, such as by the American philosopher monk Thanissaro, who erroneously uses the non-linguistic translations of "remains focused" and "alert" (instead of properly highlighting the role of mindfulness in putting aside greed & distress), as follows:
He remains focused on the body in & of itself — ardent, alert &
mindful — putting aside greed & distress with reference to the world.
He remains focused on feelings in & of themselves... the mind in & of
itself... mental qualities in & of themselves — ardent, alert, &
mindful — putting aside greed & distress with reference to the world.
This is called the faculty of mindfulness.
Thanissaro
Even worse, 20th century Burmese-American-Jewish Buddhism starts to define mindfulness as 'bare attention', which is completely wrong, embarrassing & wicked. As posted, the early Suttas say mindfulness remembers what is right vs wrong rather than suspends judgement of right vs wrong.
If we are now getting confused about how this is all supposed to work, in short, when Right Mindfulness acts to keep the mind pure (as literally said in AN 7.67), the in & breathing will naturally & automatically become the object of consciousness because, when the mind is quiet/silent, the in & out breathing becomes the grossest most discernable sense object. In other words, the term 'Anapanasati' means 'mindfulness with breathing' (lit.), ‘breathing with mindfulness’ (lit.) or 'breathing from mindfulness' (non-lit.) rather than the wicked, heretical, embarrassing 'mindfulness of breathing', which has been the translation for centuries in the history of Buddhist puthujjana.
In conclusion, the above is my 1 hour history of mindfulness. If we wish to read another opinion, we can read Bhikkhu Sujato's book A History of Mindfulness.