The foundation soil has more clay and silt content with water, river sand is used to provide uniformity for the foundation bed (especially for PCC bed).
The footing is placed directly on the rock bed, even a small sensible amount of vibration on the earth (during an earthquake) will make the structure collapse. Sand is used to minimizing that resistance.
Even though we use anti-termite in foundations, there may be some weak spots for termite entry. This is one of the reasons why we use sand (with anti-termite treatment) below the foundation.
Note: We also use M-sand instead of river sand. The process of replacing sand in concrete with M-sand has been successfully tested. Comparing to river sand, M-sand is reliable and more economic.