Given a stochastic differential equation $$ dX(t) = a(X(t), t) \, dt + b(X(t),t) \, dW(t), \qquad (1) $$ we can solve it forward in time with Euler–Maruyama scheme for a finite time step $\Delta t$: $$ X(t+\Delta t) = X(t) + a(X(t), t) \, \Delta t + b(X(t),t) \, N \, \sqrt{\Delta t}, \qquad (2) $$ with $N$ being normally distributed random number.
But I need to simulate the trajectories of the system not only forward in time from a given state, but I also need to get the history of the system leading to the current state, i.e. I need to solve the sde (1) back in time.
What would be the correct Euler–Maruyama scheme for that? I actually tried solving (2) to get $X(t)$ from known $X(t+\Delta t)$, but my back-in time trajectories seem to eventually diverge to infinities.
You need to look into "backward stochastic differential equations", which is the type of mathematical tool you use to find the history given a fixed terminal condition. The equation you show is forward by nature and it does not make sense even talking about simulating it backwards.