The vi editor was developed at U.C. Berkeley as a part of Berkeley UNIX. Before vi was developed, the standard UNIX system editor was ed. The ed editor was line-oriented, making it difficult to see the context of your editing. Then ex, a superset of ed came. It's advantage was a display editing facility. When you are working in ex, you can enter to this facility by typing vi. When this facility became frequently used, the developers made it possible to directly enter this display facility. Instead of calling ex first, just give the vi command in the prompt.
Even if you enter the vi directly, alternating between two modes (ex and vi) is still possible.