Buying or selling stocks requires access to one of the major exchanges such as the New York Stock Exchange (NYSE) or the NASDAQ. To trade on these exchanges you must be a member of the exchange or belong to a member firm. Member firms and many of the individuals who work for them are licensed as brokers or broker-dealers by the Financial Industry Regulatory Authority (FINRA).
While it is possible for an individual investor to buy stock shares directly from the company that issues them, it is much simpler to work with a stockbroker.
Until recent years, it was prohibitively expensive to get access to the stock markets. It was cost-effective only for high net-worth investors or for large institutional investors, such as the managers of pension funds. They used full-service brokers and could pay hundreds of dollars for executing a trade.
However, the rise of the internet and related advances in technology paved the way for discount brokers to provide online services with cheap, fast, and automated access to the markets. More recently, apps like Robinhood and SoFi have catered to micro-investors, allowing even fractional share purchases. Most accounts in the markets today are managed by the account owners and held by discount brokers.