I think it was probably 50/50.
Half went West for adventure and opportunity, after hearing the stories (largely myth and exaggerated) published in the East.
The other half ran away from the law, responsibilities or social customs they found objectionable (bathing and common courtesy come to mind).
What I've often thought about is that the West was filled with numerous accents: German, Irish, French, Italian, Spanish, African (in the case of escaped or freed slaves), English, Southern, Canadian, Chinese, Scandinavian, etc.
Few movies of the West have portrayed this mix of accents.
Immigrants who newly arrived on the eastern seaboard were in for a shock. America wasn't the golden land they envisioned. Most lived in squalor, in large cities, separated from others by religion, class distinctions and culture.
To them, the opportunity to go West and establish even a small farm or ranch and actually OWN land (a thing unheard of for most of them in their native countries) was a great lure.
Few realized how big America was, I'm sure, when they set out.
Of course, nearly all of this occurred well after the 1840 of which you speak, but the desire to have your own land and home transcends the ages.
Those who set out in 1840 were few, compared to the later swarm. But I suspect they also felt the urge to live free, far away from answering to any government or form of authority.
Unfortunately, humans being what they are, that lack of authority immediately led to theft, rape, pillage, murder, cheating, brutality and all manner of injustices among themselves and upon the natives they encountered.
People are people: generally nice but often brutish and greedy when they can get away with it.