What is the reason for magnetic energy and gravitational force?
This question cannot be answered simply or easily. It needs a fair amount of elaboration. Firstly, let me clarify that magnetism and gravity belong to different classes of forces. I say this in spite of the fact that ultimately one might find a way of describing all forces through a single unified theory we are not there yet. The four classes of forces that seem to describe and govern most of the universe and its phenomena are 1) Gravitation, 2) Electro-magnetism, 3) the Weak force and 4) the Strong force. Gravitation is the most familiar because things fall down when released from a height. This is also the force between any two masses merely because they have mass. It is found that gravitation also affects light or radiation. Gravity describes the planetary motions and dominates when large masses are involved. Theory of gravitation associated with the name of Newton has been modified and refined by the General Theory of Relativity, though in the ordinary world the Newtonian gravitati