Investors do not like to put money into a firm without being able to get it back out if they need it. Thus, the shares were made transferable. That means the shares can be sold to other investors. The sale of the shares from the firm to the initial investor is takes place in the primary market . The sale generates cash for the firm.
Subsequent sales take place in the secondary market and are from investor to investor.
These sales do not generate any cash for the firm. Those that own stock are the owners of the firm. They can elect a Board of Directors to look out for shareholder interests and to monitor management. This is a form of internal monitoring. This means they get paid last.