It's because there are long tactical variations after Rxd1 e5, like 1. Rxd1 e5 2. Bxe5 Re8 3. N2f3 f6 4. Nb5 fxe5 5. Rxd5+ Kc6 6. Rxe5 Rxe5 7. Nxe5 Kxb5 and 8. Nf7 wins back a full rook with a winning position. So at low depth the engine prefers Kxd1 (but changes its mind later).
Taking with the King or Rook ?

It's because there are long tactical variations after Rxd1 e5, like 1. Rxd1 e5 2. Bxe5 Re8 3. N2f3 f6 4. Nb5 fxe5 5. Rxd5+ Kc6 6. Rxe5 Rxe5 7. Nxe5 Kxb5 and 8. Nf7 wins back a full rook with a winning position. So at low depth the engine prefers Kxd1 (but changes its mind later).
Yes, I could have lost the rook or the bishop. Luckily for me that´s too deep for 1000 rating games.
Why is it better to retake with the King instead of the Rook? If I do that I will give up castling rights.
I eventually castled and it was the best move.