What MacGyver said. We had a car here that was doing almost the exact same thing and we used a volt/ohm meter to check for voltage with the battery that wouldn't work in the car and there was none. Then we put in the other battery which worked great and had voltage. It turned out that the battery cable was just out of the end terminal and when we went to the other battery which was just a little lower than the Optima, the cable would touch the end connector and work. We just got a new cable and replaced the whole cable and with new connectors and left just a little more slack in it for a taller battery.
Ron