The equation is shown below as found in the IB Physcis Data Booklet.
GPE = -GMm / r
Where GPE is gravitational potential energy, G is the gravitational constant, M and m are the masses of the objects, and r is the distance between their centres of mass.
This equation is a simplified version of the integral from inifinitity to r of the equation for the force between two point masses, which is also in the data booklet. You don't need to know how to do this integration, but you should know the definition for gravitational potential energy which comes from that equation; "the energy required to bring a point mass from an infinitite distance from M to a distance r from M". Notice that because masses attract each other, this means the masses will move towards each other voluntarily, implying that no energy needs to be put into the system. Therefore, the energy calculated from the equation is negative because the masses would still move towards each other voluntarily if energy was taken out of the system.
It is true that energy cannot be negative, but really you are using this equation to calculate the difference in potential energy between a point at distance r from M and a point at infinite distance from M. Usually you will need to use this to find the difference in potential energies at different orbits or values of r, which will be positive.