I have tried to open an account with robinhood. They said they accept H1B holders and proceeded to ask me to provide a permanent residence card; which is weird. I kept telling them I do not have a permanent residence card and they kept asking for it. Now I already have a vanguard account and I only invest long term, and don't really care much for RH but I just want to understand the legality of having a trading account for h1b holders.
Trading accounts are effectively bank accounts and have many of the same legal restrictions.
Robin Hood requires a Social Security number which means you must either be a permanent resident or have a visa authorizing you to work in the United States. If you have an H1-B, you must obtain a social security number first before applying to Robin Hood.
H1B is a work visa, so I am assuming you already have your SSN. Normally, that is enough for you to invest and save in US. What is not legally allowed is to use trading or investing as the only means of income. On H1B you need to be working only with the employer who sponsored your Visa. Other than that, you can open accounts in brokers such as vanguard, fidelity, Ally etc. You can also consider the automatic investing services such as Wealthfront or betterment to get started. You could also invest in 401K if your employer provides a match. I wrote about this at my blog too at https://guiltyinvestor.blogspot.com/2017/09/top-two-simple-ways-to-begin-investing.html