You can read about "History of general relativity" and in particular its field eqs here. In case you want a more official source, you can read MTW's Gravitation (the bible of GR) which quotes parts of official papers by Einstein. Both accounts coincide.
In short Einstein guessed the equations based on physical and mathematical intuitions. This is often the case for new physical theories. His first guess published on Nov 18 1915 was slightly wrong: he thought the Ricci tensor (a measure of curvature) was proportional to the stress energy tensor (a measure of the mass energy content). It also required some extra (bold, in his words) hypotheses. He managed to calculate the precession of Mercury perihelion and it was (surprisingly) correct. A few days later , however on Dec 2 1915 he published the eqs in its definitive form, getting rid of the extra, bold, hypotheses, and following very compelling logical/mathematical/physical/aesthetic steps. The calculation of the precession of Mercury perihelion did not change and so was still consistent with observations. This time he wrote that the Ricci tensor was proportional to a combination of the stress energy tensor and its trace. We nowadays write the eqs in its mathematically equivalent way as: the Einstein tensor (a combination of the Ricci tensor and its trace) is proportional to the stress energy tensor.
A few days earlier Hilbert (session of Nov 20 1915) managed to derive the field eqs using a simple lagrangian and the principle of least action. Apparently this was not known to Einstein.
Einstein was not able to solve the eqs for a star (a simple spherical source of gravity), but this was first solved by Schwarzschild in 1916.
Einstein could not find exact solutions to his would be eqs. However he used to linearize them, so he could find approximate solutions to weak gravitational fields, the same fields that we find in our solar system. This is how he managed to correctly calculate the precession of the orbit of Mercury