Here is an analysis of a vertical, 1/2 wavelength, 2 meter dipole suspended at various heights above ground:
As you can see, as you raise the bottom end of the antenna from near ground level up to about 7 wavelengths, the gain increases. At the same time, the elevation angle of the maximum gain decreases (becomes closer to the horizon). As you continue to raise the height of the antenna, the gain becomes somewhat cyclic but the elevation angle remains low.
If you put the bottom end of the antenna directly in contact with the ground, or buried in the ground, the gain will further decrease and the resonance of the antenna will shift. Ultimately, it would be preferable to have a 1/4 wave monopole with an appropriate number of ground or elevated radials in order to realize the maximum gain of this configuration. See How Does Earth Conductivity Affect the “Takeoff Angle” of a Vertical Monopole? and How Does the Performance of Elevated Radials Differ from That of Buried Radials? for more information regarding the ground wire construction implications of 1/4 wave vertical ground plane antennas near the earth.