I did a practice problem set. I was given a production function $F(K,L)$ and had to derive the firm's cost function. To do this, I used the following relationship:
\begin{equation} \frac{MP_L}{MP_K}=\frac{w}{r} \end{equation}
I found this formula in a set of lecture notes online. I have no idea where it comes from. I understand what $MP_K$, $MP_L$, $w$, and $r$ are but I don't know why these ratios are equal. I got the problem correct, but I want to understand this point better.
My Question:
Can someone explain why this ratio is true?