Yes, you are correct in your understanding that Einstein's Special Relativity (SR) was developed to reconcile Maxwell's Electromagnetism (EM) with classical mechanics. However, SR only applied to non-inertial reference frames and did not account for gravity. This led Einstein to develop General Relativity (GR) which extended SR to include gravity and was able to explain the observed phenomenon of gravitational lensing.
However, as you mentioned, Einstein did spend a significant portion of his later years trying to find a way to unify GR and EM. This is because while GR successfully explained gravity, it did not fully align with the principles of EM. For example, GR predicted the existence of gravitational waves, while EM did not have a concept of waves in its equations.
Additionally, GR and EM had different mathematical frameworks, making it difficult to combine them into a unified theory. Einstein believed that there must be a deeper underlying principle that could unite these two theories, and he spent much of his later years searching for this unification.
It wasn't until the development of quantum mechanics and the theory of quantum electrodynamics that a possible unification of GR and EM became apparent. This eventually led to the development of theories such as string theory and loop quantum gravity, which attempt to unify all of the fundamental forces of nature, including gravity and electromagnetism.
In short, while SR was compatible with EM, GR introduced new concepts and principles that were not fully aligned with EM, leading Einstein to continue his quest for a unified theory until his death.