Anything that has mass will have gravity ( Exhibit a phenomemon called gravitation) not just black holes.
One way of understanding gravity was put forth by Newton as his law of gravitation. As @christo said, there is no clear knowledge of why it has gravity.
A more generic way to put it would be to say, anything that has mass curves the space around it. The force or gravity you would feel can be considered as the way you are being forced to follow the curved lines instead of your intended path. This is how Einstein's general theory of relativity explains gravitation.
In quantum mechanics, It is speculated that gravity is caused by exchanging particles called gravitons, think of it like the way you would play catch with your friends. Multiple objects having some mass throwing small balls called gravitons at each other. There is no evidence for the existence of gravitons yet, but it explains a lot of things in the quantum realm.