Why add a minus sign in the formula for gravity?

The minus sign is to indicate that the force is attractive: if there was no minus sign, two masses would repel.

By the way, Wikipedia's article is correct: the vector F must point away from the mass on which the force is acting ($m_2$), and $\textbf{r}_{12}$ points to the mass $m_2$, so with a minus sign you need $\textbf{r}_{12}$; otherwise you would have repulsion.

If it seems redundant to you (using the vector pointing to $m_2$ and introducing a minus sign - why not just use the opposite vector $\textbf{r}_{21}$ and cancel the minus sign?) well you are right in a sense, because when speaking of force this indeed looks a bit of a cramped reasoning. The real reason is that physicists like to think to forces in terms of fields. You can take a look at the Wikipedia article about the gravitational field. Under this light, it makes much more sense to use the vector $\textbf{r}_{12}$ because it can be identified with the position vector (which has nothing to do with the mass $m_2$ anymore - this is the power of the concept of field as opposed to the force-between-objects concept)


To answer to this question, try to make a scheme of the situation.

You have two masses $m_1$ and $m_2$. By definition, the subscript on the forces will have as first number the index of the mass that causes the force and as second one the index of the object on which this force is applied. Since you are evaluating $F_{12}$ and we know from our physical intuition that gravitational force is attractive, you can draw it as directed from the center of mass 2 toward the center of mass 1.

If you then analyze the definition of the vector $\vec{r}_{12}$, you can see that it is defined as: $$\vec{r}_{12} = \vec{r}_2 - \vec{r}_1$$ and by applying the rule for adding vectors, you can see that it should be directed from mass 1 to mass 2. Then, normalizing it you can have the relative unitary vector $\hat{r}_{12}$.

enter image description here

From the diagram, you can then see that $\vec{F}_{12}$ and $\vec{r}_{12}$ are on the same line, but pointing in different directions: the minus sign is due to this difference.

The same applies to your book, where I suppose it is used a different convention to label subscripts of forces.

These equations could be written without the minus sign just by choosing a different unitary vector, with the right direction. On the other hand, the minus sign is relevant because it is conventionally associated with attractive forces. Of course, the gravitational force is always attractive, so this minus sign is always present, but in different kind of forces such as Coulomb force, a negative module means an attractive force while a positive module means a repulsive one, and the sign of the module comes from the sign of the charges.