The answer to that is simply density. If the material is more dense than the fluid that surrounds it, it’ll sink if it’s less dense it’ll float. So in short, the answer is that ice floats because frozen water is less dense than liquid water. But
how is that possible? isn’t it all just water and aren’t solids like definitionally more dense than a liquid. Well not definitionally. Usually yes, but water molecules are special in the way that they’re shaped and how their electrons are distributed around them.