Shares represent an obligation for a company to repay you, unlike debt or bonds. They represent “ownership” of the firm (not from a legal standpoint, though) and are generally accompanied by voting rights that afford the owner some measure of control.
Shareholders benefit in the form of capital appreciation (i.e., the stock price increasing) or in dividends.