You can find the answer here, namely $\displaystyle {40\choose20}^2$, but I don't know how to justify that rigorously.

If you want to get a feel for how this works, try to work out how many routes there are for a smaller number of steps, say four steps or six steps, which should be easier than 40 steps. As an example, in the case of four steps there are nine lattice points that you can reach after two steps (including the origin itself, which you can reach in four ways). For each of these, write down how many ways there are of getting there in two steps. You should arrive at a picture like this:

Code:

1
2 . 2
1 . 4 . 1
2 . 2
1

(The dots indicate points like (1,0) that you can't reach after two moves.) For each of these destinations, there is an equal number of ways of getting back to the origin after another two moves. So the total number of ways of getting back to the origin after four moves is $\displaystyle 4^2+ 4\times2^2 + 4\times1^2 = 36$. Notice that if you look along the diagonals (is that where the hint about the 45-degree rotation comes from?), you see the binomial coefficients 1,2,1 multiplied by 1,2,1. For a journey of 2n steps, that suggests that the total number of possible routes is $\displaystyle \sum_{j,k=0}^n{n\choose j}^2{n\choose k}^2$, which is equal to $\displaystyle {2n\choose n}^2$.