Suppose a bakery has flour for 50 loaves and yeast for 40. However skilled the bakers, 40 loaves is the most they can make, and that ceiling is the theoretical yield. In chemistry the ceiling comes from the balanced equation and the reactant that runs out first. Heating limestone, CaCO3→CaO+CO2, from 10.0 g of CaCO3 (0.0999 mol) can make at most 0.0999 mol of CaO, which is 5.60 g.
The calculation is stoichiometry with two guard rails. First, use the limiting reactant: with 2.0 mol of H2 and 2.0 mol of O2 in 2H2+O2→2H2O, hydrogen runs out first, so the ceiling is 2.0 mol of water, 36.0 g, not the 4.0 mol the oxygen alone could make. Second, finish in grams, because a product is weighed on a balance; 0.100 mol is not yet a yield you can compare with a weighing.
Theoretical yield is a prediction, not a measurement. The amount you actually collect, the actual yield, is almost always lower: some reactant doesn't react, side reactions make other products, and crystals stick to the filter paper. A collected mass above the theoretical yield doesn't mean a better reaction; it usually means the product is still wet or impure. Dividing actual by theoretical gives the percent yield.
Think of it like this. Theoretical yield is the number of full place settings you can lay from the cupboard: 12 plates and 9 cups make at most 9 settings, however carefully you work. A clumsy evening with a broken cup gives fewer, which is the actual yield; nothing you do can give more.
Core idea. The theoretical yield is the most product a reaction can make: the limiting reactant's moles, carried through the coefficient ratio and the product's molar mass. It is a calculated ceiling, so real results fall below it.