Cosmology and prospects for sub-MeV dark matter in electron recoil experiments