Its part of the central locking unit control wiring, it has a connection to vehicle speed sensor and also rpm signal and gear position switch (if auto)
It has been present since the 70s in toyota crowns (albiet vacuum controlled)
In 100 and 120 corollas its very easy to retrofit a unit from another toyota that has such features, the wiring is already in place.
140 is slightly different and later ones have linbus, easiest if you know how to work on it. But impossible if you dont.
It works like thusly, engine running car in gear, speedo registers above 15 kmh, it will send momentary signal to door motors to pull in the locks, it will keep it locked and will resend signal immediately if unlock is detected from locking motor position switch.
When car is slowed to stop and put in Park it will unlock (this can be disabled via a jumper setting on older toyotas), in manual gear models it doesnt unlock till engine key is switched off. (This can also be selected to unlock the driver door or all doors)
It requires the original door lock motors with position switch to be present.