How do I apply for an E-2 visa?

It depends if you apply while in the US or not.
(a)    Outside the United States:
Apply at the U.S. consulate of your place of nationality. The application is done through the DOS Online Visa Application. See link for details on what the process of applying for a visa entails: https://travel.state.gov/content/visas/en/employment/treaty.html.

(b)    Inside the United States:
You must be in lawful nonimmigrant status.  For more detailed instructions on filing with the USCIS, the link is:
https://www.uscis.gov/working-united-states/temporary-workers/e-2-treaty-investors