What is the occasion, the reason for writing it or historical occurrences that caused it to be written, for Self-Reliance?
Emerson is considered one of the big names in Transcendentalism in New England in the mid-19th century. The Transcendentalists were reacting against established religious doctrine (Unitarian church) and the rationalism and empiricist thought. In other words, they were reacting against the idea that rational (logical) and empirical (knowledge gained by sense experience) practices were enough to improve the society. Remember that this was shortly before the Civil War; Abolition and Women's Rights were popular debate as this period was the first Civil Right's Movement. If slavery and other inequalities had not yet been overturned by the so-called rational and enlightened powers that be, the transcendentalists were suggesting a more intuitive/spiritual way of approaching the world.
In general, as part of the transcendental movement, "Self-reliance" was a motivation of the individual, a reaction against social structures, conformity and a call to avoid being swept along by the force of history. To think individually, (which Emerson says is divinely inherent) is to become the master of your (and your society's) own fate. Times of great change require individual thinking. And this was certainly the case in America and Europe in the mid 19th century. Across the Atlantic, the Romantics were the counterpart to the Transcendentalists and 1848 would see the beginnings of Marxism; all reactions to the status quo.