This is probably because it's supposed to be like a protostar. This also explains why it's really heavy for it's tiny size. Stars are really dense, so they are really heavy for their size. If the sun was so light for it's size that it had less gravitational influence than the Earth, the Sun would orbit around the Earth. But as it is, it's the other way round, and the Sun stays still in space, and just spins round a bit. (Well, it also orbits around the centre of our galaxy, but that's even heavier.)
So it floats because it's so heavy that it has it's own gravitational influence. I know 999Kg isn't enough for something to have it's own gravitational influence, but it's weight is actually recorded as 999 .9 Kg. Maybe it's really more than this, because it's off of the weight scale, and 999.9 is the highest number it can show. It's even heavier than primal Groudon (999.7Kg). So it's now the new heaviest Pokemon, by what looks like a tiny bit, but really by a long way, because it probably weighs millions of kilograms to have it's own gravitational influence.
But this doesn't mean that it should have levitate. If you send it out into battle, it would sit on the floor and not be able to move without great difficulty (which explains it's base speed). It's floating in the picture because it evolved from cosmog while in the air. And cosmog can be in the air because it can float upwards momentarily because it's a gas. And after this picture, Cosmoem can be pulled around by Lillie's bag from that height. And when it floats higher in the air above the altar of the sun/moon, that's because the altar is so powerful it can lift it that high.