Market makers are individuals or representatives of firms whose function is to ensure liquidity in the securities markets, through bids and offers to the public in the absence of an offer from a counterparty. When traders place an order to buy a certain security which nobody is queuing to sell, market makers sell that security from their own portfolio or reserve. Similarly, they will buy a security in absence of other buyers.
In doing so, market orders are continuously moving, eradicating sudden surges and ditches due to buying and selling imbalance. Market makers earn profits through a spread between their buying price (bid) and their selling price (ask). The ask is always higher than the bid, allowing the market maker to profit from their inventory.