We investigate the physical conditions of ionized gas in high-z star-forming galaxies using diagnostic diagrams based on the rest-frame optical emission lines. The sample consists of 701 galaxies with an Ha detection at $1.4lesssim zlesssim1.7$, from the FMOS-COSMOS survey, that represent the normal star-forming population over the stellar mass range $10^{9.6} lesssim M_ast/M_odot lesssim 10^{11.6}$ with those at $M_ast>10^{11}~M_odot$ being well sampled. We confirm an offset of the average location of star-forming galaxies in the BPT diagram ([OIII]/Hb vs. [NII]/Ha), primarily towards higher [OIII]/Hb, compared with local galaxies. Based on the [SII] ratio, we measure an electron density ($n_e=220^{+170}_{-130}~mathrm{cm^{-3}}$), that is higher than that of local galaxies. Based on comparisons to theoretical models, we argue that changes in emission-line ratios, including the offset in the BPT diagram, are caused by a higher ionization parameter both at fixed stellar mass and at fixed metallicity with additional contributions from a higher gas density and possibly a hardening of the ionizing radiation field. Ionization due to AGNs is ruled out as assessed with Chandra. As a consequence, we revisit the mass-metallicity relation using [NII]/Ha and a new calibration including [NII]/[SII] as recently introduced by Dopita et al. Consistent with our previous results, the most massive galaxies ($M_astgtrsim10^{11}~M_odot$) are fully enriched, while those at lower masses have metallicities lower than local galaxies. Finally, we demonstrate that the stellar masses, metallicities and star formation rates of the FMOS sample are well fit with a physically-motivated model for the chemical evolution of star-forming galaxies.