The way animation with key frames works is that only specified data values (e.g., location and rotation) AT the key frames are remembered, not how they got there.
If you focus on just one of your spheres -- say the one at the top left -- at the first key frame, it's in the top left position with a particular orientation. At the second key frame, it's in the bottom right position having been rotated 180 degrees. The way Blender animates between these two keyframes is to, roughly, linearly interpolate between those locations and rotations, so it moves the sphere in a straight line from the top left to the bottom right, and it smoothly rotates it 180 degrees around its axis while doing so. It does this separately for all 10 spheres, so they look like they all just move independently to their new positions along separate straight lines, ruining your animation.
There are two approaches to fixing this.
First, you can add more key frames. If you added key frames each rotated an additional 30 degrees for a total of a 180 degree rotation of your arrangement, then Blender would interpolate between those states and show you a pretty smooth rotation. This is probably the easiest method to incorporate into your current animation. It's straightforward and flexible, though a little tedious.
Second, you can change the structure of your arrangement so Blender's method of interpolating object data between two key frames leads to the correct result. Hypothetically, if you selected all ten of your spheres and typed Ctrl-J to join them into a single mesh, and then set the origin to the center, then they would rotate as a unit based only on the rotation of that new, single object. If you had two key frames, one with a rotation of 0 and another with a rotation of 180, then a smooth linear interpolation between those two rotations would give an animation that smoothly rotates the entire arrangement. (There would still be an ambiguity -- Blender wouldn't know if you wanted to rotate clockwise or counterclockwise, so you'd probably want to add a keyframe at the halfway point to break the tie.)
Now, this method wouldn't work for you. Once the spheres had been joined into a single mesh, you couldn't easy animate them independently any more, so it would ruin the rest of your animation.
There are ways around those, though they may be a little advanced. You could parent the ten spheres to an invisible rotation object that only gets used when they need to rotate together. Or, you could keep two copies of your objects around -- one with ten separate spheres, and another joined mesh for rotations, and then swap them out (make one invisible and the other visible) between frames as needed. I don't have a lot of experience with animation in Blender, so maybe someone has some better ideas.
In the meantime, extra key frames are probably the easiest way to go.