We study the formation of a nanobubble around a heated nanoparticle in a bulk liquid by using molecular dynamics simulations. The nanoparticle is kept at a temperature above the critical temperature of the surrounding liquid, leading to the formation of a vapor nanobubble attached to it. First, we study the role of both the temperature of the bulk liquid far away from the nanoparticle surface and the temperature of the nanoparticle itself on the formation of a stable vapor nanobubble. We determine the exact conditions under which it can be formed and compare this with the conditions that follow from a macroscopic heat balance argument. Next, we demonstrate the role of dissolved gas on the conditions required for nucleation of a nanobubble and on its growth dynamics. We find that beyond a certain threshold concentration, the dissolved gas dramatically facilitates vapor bubble nucleation due to the formation of gaseous weak spots in the surrounding liquid.