Apollo lunar launch azimuths, and hence the resulting orbital inclinations, varied as a function of time during each launch window. Since the launch pad didn't rotate, the launcher had to perform a variable roll after liftoff.
The IMU on the CM had only 3 gimbals. During launch, the reference direction (REFSMAAT) was oriented so that the gimbal lock positions (think of the poles of a globe) coincided with 90 degrees of out-of-plane yaw. So as long as you rolled so that the spacecraft Z axis (running parallel to the astronauts in their couches) was in the orbit plane, yaw was kept small and there was no risk of gimbal lock.
Another reason (often the main one, in fact) to roll a launcher after liftoff is to keep various antennas pointing in the right directions. The Saturn V had probably a dozen VHF telemetry transmitters. It also had UHF range safety (destruct) receivers, but those had multiple antennas since you couldn't depend on them facing in the right direction when you needed to send the command.