$n$ comes from how the density of any component of the universe scales as the universe expands in the FLRW metric. For matter, $n=-3$ since the mass of matter is conserved.
$\omega$ comes from the equation of state for any component in the universe.
$$ p = \omega ρ $$
Pressure equals omega times energy density. For matter $\omega = 0$, matter, often termed dust, has no associated pressure. And you can see how the formula in the question works.
$$ -3 = -3(1+0) $$ For dark energy, $n = 0$ and $\omega = -1$. That also works $$ 0 = -3(1 + -1) $$ But I can't for the life of me see why $n$ and $\omega$ should even be related, let alone by this formula.