We use optical data from the Palomar Transient Factory (PTF) and the Catalina Real-Time Transient Survey (CRTS) to study the variability of gamma-ray detected and non-detected objects in a large population of active galactic nuclei (AGN) selected from the Candidate Gamma-Ray Blazar Survey and Fermi Gamma-Ray Space Telescope catalogs. Our samples include 714 sources with PTF data and 1244 sources with CRTS data. We calculate the intrinsic modulation index to quantify the optical variability amplitude in these samples. We find the gamma-ray detected objects to be more variable than the non-detected ones. The flat spectrum radio quasars (FSRQs) are more variable than the BL Lac objects in our sample, but the significance of the difference depends on the sample used. When dividing the objects based on their synchrotron peak frequency, we find the low synchrotron peaked (LSP) objects to be significantly more variable than the high synchrotron peaked (HSP) ones, explaining the difference between the FSRQs and BL Lacs. This could be due to the LSPs being observed near their electron energy peak, while in the HSPs the emission is caused by lower energy electrons, which cool more slowly. We also find a significant correlation between the optical and gamma-ray fluxes that is stronger in the HSP BL Lacs than in the FSRQs. The FSRQs in our sample are also more Compton dominated than the HSP BL Lacs. These findings are consistent with models where the gamma-ray emission of HSP objects is produced by the synchrotron self-Compton mechanism, while the LSP objects need an additional external Compton component that increases the scatter in the flux-flux correlation.