It should be noted that it is not necessarily every five days. Orbital motion calculations are performed every production cycle (whatever you have that set to) and the body positions updated then.
The reason that the X/Y coordinates are stored is so that you can have one function that sets where a TG is moving (or a mineral packet / missile /etc is being sent). That function just looks up the X/Y position of whatever target object (lots of tables in the game have an X/Y coord, and many also have a "last x" / "last Y" so that you can draw the movement trails as well).
As for the question about what happens if a planet / body moves when a ship is trying to go there, it depends on what order things happen during the production cycle. If planets move first, there is no problem, as the X/Y for the body will be updated before the ship tries to figure out how to get there. I would assume body motion comes first for this reason, but it's possible it may not. Just watch a slow conventional engine freighter trying to catch up with a planet and you will see that they aren't doing any kind of predictive motion interpolation. They just head directly for the body.
As for why to store X/Y for each object rather than calculate it on the fly each time, that should be obvious. Performing a calculation is almost always going to be slower than a simple DB lookup. When you compound this with potentially thousands of calcs/lookups every increment, it can get slow pretty quick.