Company needs capital to start or expand the business. They planned to collect the money from people.They submit their documents for getting the approval from SEBI to initial public offer- IPO.After getting approval, people get the shares based on the subscription price. If more no of people applied, allot by random method. Others get the refund . This is primary market. Share holders can exchange their shares in exchange. This is secondary market. Dividend is provided by the company from the profit.