Chemical pre-processing of cluster galaxies over the past 10 billion years in the IllustrisTNG simulations