When someone lends their cryptocurrencies / "tokens" to a borrow/lend protocol, they are said to be "providing liquidity". In return, this person earns commission on the trades they facilitate. The commission is paid out in the same tokens they are providing.
Yield farming, also called "liquidity mining", is when liquidity providers earn a third token, in addition to their commission (or sometimes instead of commission). This third token is the "currency" of the borrow/lend protocol, and often confers certain rights to the holders, for example voting rights on protocol changes. This token is exchangeable for other tokens / digital currencies, so it has monetary value.
Examples of protocols that support liquidity mining, and their respective tokens, include Compound (COMP), Curve (CRV) and iearn (YFI).
Protocols that reward liquidity providers with their own token do so in proportion to the amount of liquidity each person provides. If you are the first to provide liquidity to a new protocol, you will earn 100% of the rewards, until someone else comes along and takes some of your market share.
So it can be lucrative to be first. But there are risks with yield farming / liquidity mining.