Hydrogels are highly flexible network polymers being developed as scaffolds for tissue engineering and joint replacement. Their mechanical properties depend largely on their water content. To determine the associated mechanical and thermodynamic properties, we apply the new two-phase thermodynamics method (2PT) to short, molecular dynamics (MD) trajectories of solvated carboxybetaine methacrylate (CBMA) hydrogels. The calculated optimum water content agrees well with recent experiments. We find that the thermodynamics is dominated by a competition between the enthalpy of tightly bound water molecules (which enhance the population of low-energy states of the hydrogel) and the entropy-driven formation of a quasi-liquid water phase in the void volume. These new insights into the role of water in stabilizing hydrophilic motifs is expected to guide design strategies aimed at creating hydrogels with improved performance.