氷の上を滑る
This を in this phrase called the transition marker, and can equate to the English phrases "along", "through", and "across". It is used with intransitive verbs of mobility or motion.
In this example, the literal meaning is "to skate across the top of the ice."
From Tae Kim:
The only time you can use the 「を」 particle for intransitive verbs is when a location is the direct object of a motion verb as briefly described in the previous section.
From IMABI:
Transitioning through a dimension of time is one of the most important applications of the transition marker を. To visualize how this works, think of a circle and arrow going through it. The action at hand happens anywhere throughout the space wo を marks. Transition-wise, it may equate to various English phrases such as “along,” “through,” and “across.” [...] The verbs this usage is used with are intransitive verbs that all involve motion.
Here are some more examples:
- 富士山を登りました。
I climbed Mt. Fuji.
- 公園を走りました。
I ran through the park.
- 日本橋を渡りました。
I crossed the Nihon Bridge.
- ミシシッピ川を泳ぎました。
I swam across the Mississippi River.
- 空を飛びました。
I flew across the sky.
In regards to the difference between に and を, に can be used but it is a direct destination rather than transitioning "through" or "across". For example:
- スーパーに行く。
I go to the store.
- 僕の道を行く。
I walk along my path.
Here is the relevant explanation from the same IMABI page:
As the examples above have demonstrated, the transition marker wo を is used to indicate what dimension movement is taking place. However, the particle wo を says nothing about destination or what may happen internally within a certain dimension. Those situations are handled by other particles. The verb iku 行く means “to go,” and is frequently described as taking the particle ni に, which indicates destination. However, it too can be used with the particle wo を. In the case of iku 行く, the sentence becomes figurative as it goes beyond the typical application of “to go (somewhere).”
In this case it wouldn't really make sense to say 氷の上に滑る, since the top of the ice isn't the destination of the movement, it is the location through which the movement happens.
These questions have some related details as well: