Before the VAB, every rocket was assembled on the launchpad. Having a crane there was standard.
Apollo 10 had the launch escape tower removed on the launchpad to modify the docking ring. This probably was done by the hammerhead crane.
Apollo 12 had a hydrogen tank in the service module changed out on the launchpad. The hammerhead crane was likely involved.
The crane was kept for a while into the Shuttle era with the intention of loading payloads at the launchpad.
Unless stated otherwise, sources are The Kennedy Space Center Story.
Before the VAB
We are so used to the idea of a Vehicle Assembly Building that we forget that rockets used to be assembled on their launchpad. Stages which had been delivered from the manufacturer would be stacked by a crane at the pad, checked out, fueled, and then launched.
Every Saturn I and IB rocket of the 1960s was handled this way, at launch complexes 34 and 37. That was every unmanned Apollo flight (except Apollo 6, which was a Saturn V), the Apollo 1 disaster, and Apollo 7. These launch complexes had a mobile service tower with a crane to lift to vehicle parts, and shutters to protect the vehicle during hurricanes and other storms. Prior to launch, the service tower was rolled away on rails.
The Saturn V was way too big to be assembled and checked out at the pad. Instead, they would be handled in the safety of a massive, permanent building, on top of a mobile launch platform (MLP). When the vehicle was finished, it would be driven on top of the MLP to the launch site. The director of KSC, Dr. Kurt Debus, sketched the design of the MLP. It would be topped by a 25-ton capacity crane:
Ingalls Iron Works of Birmingham, Alabama, began to erect the
structural steel of the first launcher in July 1963, and topped out the third launcher in March 1965. When the first was topped by the installation of a 25-ton hammerhead crane, Ingalls arranged a luncheon under the launcher base for 300 hard-hatted construction workers whose on-time performance won the plaudits of the KSC Director. Then NASA and Ingalls officials and employees cheered as the crane surmounting the tower was smoothly hoisted into position.
I have been unable to find the specific reason for that crane. However, having a crane at the launch pad was already standard practice. Also, about a half-dozen documents and webpages at NASA use exactly the same phrasing for the hammerhead's purpose:
A hammerhead crane atop the fixed service structure provides hoisting services required in pad operations.
Here is a March 1965 picture with all three MLPs complete, including their hammerhead cranes. The VAB is still under construction, and would be structurally complete June 1965.
While the MLPs and VAB were under construction, Saturn Is were being launched at 34 and 37. Had the construction of the VAB fallen behind schedule, the hammerhead cranes may have allowed some missions to be assembled at pad 39A.
The first product of the VAB was SA-500F, a Saturn V test article used to practice procedures in the VAB, on the crawler, and at the launch pad. While testing on the launch pad on June 8, 1966, a hurricane was forecast for the next 24 hours. Debus gave his crew 12 hours to get the vehicle back safely to the VAB. They did it in 10 hours!
Every Saturn V used the VAB and the MLPs. This included the unmanned Apollo 6, the manned Apollo 8-17 missions, and the unmanned Skylab launch. Although the manned Skylab 2-4 and the Apollo-Soyuz Test Project used Saturn IBs, they also used the VAB and MLPs, via the famous "milk stool".
The hammerhead crane may have been needed to remove the launch escape tower at the pad for Apollo 10:
As the flight readiness test was completed April 9, the launch escape tower had to be removed at the pad to permit modification of the docking ring area in Apollo and the liquid oxygen replenishment system was retested.
Apollo 12 needed a fuel-cell hydrogen tank replaced on the pad. Its replacement came from the Apollo 13 service module, immediately below the ill-fated oxygen tank. Considering that the hydrogen tank was a 32-inch diameter titanium sphere, it is plausible that the hammerhead crane would be needed:
Two days before the November 14 launch of Apollo 12, a hydrogen tank in the service module acted up. One tank was removed from Odyssey and installed in Yankee Clipper on the launch pad as the suspect tank was taken out. A replacement tank was installed in Odyssey.
I have been able to confirm that each of these problems occurred and were repaired before launch, but only one source mentions that they were repaired on the pad. The hammerhead crane (or any other detail of the repair) is not discussed, but is plausible.
The Shuttle Era
This 1974 study of Shuttle-Centaur describes a procedure to load payloads on the launch pad:
The Orbiter payload is brought to the base of the changeout tower on a ground transport trailer, transferred to an erector, raised to a vertical attitude and lifted by changeout tower hammerhead crane to the vestibule of the changeout room. Entry to the vestibule can be up through the floor, through rear doors, or down through an overhead door. The payload is positioned in a payload changeout unit and moved to the cleanroom. Inside the cleanroom, with the payload bay doors open, the payload is installed in the Orbiter with the payload changeout unit. With umbilical mating completed and work platforms withdrawn, the payload bay doors are closed, seals released, and the cleanroom withdrawn to launch position with blast screens in place.
The hammerhead crane was removed in 1994:
An Apollo-era hammerhead crane, a recognizable feature at the top of the FSS in early shuttle launch photos, was removed from Pad A in December 1994 when it became more cost-effective to use a mobile crane than to maintain the hammerhead crane, experiencing the corrosive effects of the sea air.