In I2C bus protocol What is role for Combination of Pullup resistor and Slave device pin Capacitance?
i2c is an open drain bus, which means the devices are able to pull the bus down, but not high. To pull the bus High you need the resistor.

The resistor value is determined mostly by the devices pull down capability and the bus capacitance. If capacitance is too high, you need a stronger pullup (lower resistance), if resistance is too low, the devices struggle to pull the bus down.

This article has nice examples of the effects of different resistor values in an i2c bus.

This other contains a brief open drain explanation by Maxim.

You have to choose your pullups (and sometimes drivers) depending on how capacitive you expect your bus to be (wire and traces, not just the pins themselves).

Note that i2c was conceived to be used in devices close by, as in same PCB or a couple of meters apart.