Controlling the dynamics of a coupled atom-cavity system by pure dephasing