By definition, economic resources are limited. We never have enough land, labor, capital, or entrepreneurship to use on all of the things that we would like to produce and consume. This is the fundamental problem of “scarcity” on which all of economics is based. The fact that scarcity exists leads directly to the existence of opportunity costs.
Opportunity costs are the value of what you forego when you choose to undertake a certain economic activity. For example, let us say that I am a farmer and I want to plant some corn. I have a certain (limited) amount of land on which to plant crops. If I plant corn on a certain plot of land, I cannot plant onions or wheat there. Let us say that onions would have been my next choice. So, my opportunity cost for planting corn is that amount of onions that I could have grown on that land.
Because our resources are limited, we have to make choices about how to use them. When I use a resource to make one thing, I give up the opportunity to use that resource to make something else. That is how scarcity is related to opportunity costs.