The robotic fish propelled by a passive flexible tail can perform the undulation regulation of natural fish better than using a rigid tail owing to its smooth curvature. Moreover, it has been observed that fish change the stiffness of their bodies to adapt to various swimming states. Inspired by this, a stiffness optimization scheme is explored for a novel elastic tail, which can improve the performance of the robotic fish. Spring steels are used as passive flexible joints of the fishtail, which can be easily expanded into multi-joint structures, and the joint stiffness can be altered by changing the joint size. In this study, the Lagrangian dynamic method is employed to establish the dynamic model of the robotic fish, where passive flexible joints are simplified by a pseudo-rigid-body model. In addition, the hydrodynamics of the head and tail are analyzed using the simplified Morison equation and quasi-steady wing theory, respectively. Furthermore, to determine unknown hydrodynamic parameters in the dynamic model, a parameter identification method is applied. The results show that the identified simulation speeds fit the experimental speeds well within a wide range of stiffness values. Finally, to improve performance, the influence of joint stiffness and frequency on swimming speed is investigated based on the identified dynamic model. At each frequency, the optimal joint stiffness distribution is to reduce the stiffness from the front to the rear. At the maximum driving frequency of 2.5 Hz, the optimal swimming speed is 0.3 BL/s higher than that of using rigid joints.