When you buy shares of a company, you are "giving" money to a company so that they can use it to fund things for their business (Infrastructure..blah).
A share is a part ownership of a company. So if Microsoft had 100,000 shares and you bought 1 share, you have 1/100,000 part ownership of Microsoft.