Thoroughly familiar with the immigration system.
The short answer is, without making a 'large' investment (i.e. $500K min) + showing that you can provide at least 10 jobs in 2 years - you have a steep climb to be able to stay in the US.
That being said, anyone can register a company - from any country. You can have the company in the US, register a bank account, get a tax ID, pay taxes, etc....but unless you are doing a certain amount of business and creating at least 10 jobs, you can't actually live here.
People will say you can register a company on a student visa (F1), that's BS. Don't do it. You might not get caught immediately, but it violates the intent of the student visa - which is a 'non-immigrant student visa'. i.e. you have no intention of staying in the US. You are just there to work.
The same applies to H1-B, and other work visas. All of those visas are non-immigrant visas, which means you don't intend to migrate to the US permanently.
Some people have successfully started a company on F1, but if you ever get audited by the US Immigration service, there is a very high probability that you will get deported.
All of that being said, don't worry about it. You can travel to the US on a visitors visa, or a business visa, for a few months (for e.g. to participate in YC), and then go home - while still having your company operating in the US. Once you are big enough, if you sell to a large company, like Facebook or Google or something, they can do an internal transfer (I believe it is a J-visa).
Also, there are paths to a green card (family, marriage, or investment) that given your situation the best would probably be investment once your company grows enough for you to open an office in the US.
All of that being said, make sure to see an immigration attorney and get good advice. But more importantly, read the various requirements for yourself - from the links others have posted here.
Some attorneys might tell you they can get you a green card through an F1 or H1-B....make sure you know your stuff, and be suspicious.
I have many friends that have told me that they have spoken to attorneys that assure them they can start a company on an F1 visa. I have spent hundreds of dollars and visited at least 4 different attorneys (including a past immigration judge) and they all tell me the same thing. By doing that, you violate the intent of the law.