Light does bend when it passes from one medium to another with a different refractive index, a phenomenon known as refraction. This bending of light occurs due to a change in the speed of light as it transitions between mediums.
However, in a vacuum, where there is no material medium, light does not experience refraction. This is because the refractive index of a vacuum is defined as 1, and light travels at its maximum speed in a vacuum (approximately 299,792,458 meters per second, often denoted as "c"). Since there is no change in the speed of light, it continues to propagate in a straight line without bending.
The behavior of light as a wave is not contradictory to its straight-line propagation in a vacuum. Waves can exhibit different behaviors depending on the medium through which they travel, and the absence of a medium in a vacuum prevents refraction from occurring.