As far as originally adding the term,
It was a prejudice of the time that the universe was constant and eternal, forever unchanging — at least on the largest levels. This led Einstein to add a term to his initial equations in 1917. While the original formulation of general relativity included only the attractive form of gravity, this new term, called the cosmological constant, was a repulsive term. The attractive and repulsive forms of gravity could be tuned to balance one another, resulting in a stationary and unchanging cosmos.
When Hubble published his paper in 1929 showing the universe to be expanding, Einstein reassessed:
With the realization that his earlier prejudice for an unchanging cosmos was wrong, Einstein removed the cosmological constant from his equations. He was reported by physicist George Gamow as having called it his "biggest blunder."
Excerpts taken from Don Lincoln's Op-Ed.
On your clarification, allowing expansion in the original field equations was not his intention. Einstein was chasing after general covariance, and his underlying assumption of a static universe was apart from him arriving at this invariance of physical law. It was only when Friedmann and Lemaître found expanding solutions to his field equations that he modified it,
sticking in the cosmological constant in order to permit steady-state solutions (the only ones he thought to be physical). However, the solutions to this modification were unstable, and a handful of years later Hubble came along to shed some light on the matter.