why does light travels in a straight line?
Why does anything travel in a straight line,then?
It doesn't always travel in a straight line. Consider diffraction, for example. Or refraction through a medium with a continuously varying index of refraction, which produces mirages:
and another couple of examples of why it doesn't always travel in a straight line.
gravitational lensing small scale of starlight around our sun ......
and lensing on a large scale
the thin arcs of light you can see is from a galaxy or maybe more than one that is beyond the foreground galaxies. The gravitational lensing of those foreground galaxies is diffracting the light, so we can see the galaxy(ies) hidden behind them .....
As others have pointed out, this question is poorly phrased because light only travels in a straight line under certain conditions (such as moving in the absence of significance gravitational effects and through vacuum or a homogeneous medium).
But we can reword the question to be "Why does light travel on the paths that it does, including a straight line in empty space?", and that might still be close to what @thecosmos123456 had in mind (if not, he can post to correct me). If that's the question, the answer is that it follows from the laws governing the propagation of electromagnetic waves. Googling for "Maxwell's equations" and "light wave equation" will find many explanations, although some may be fairly mathematically demanding.
Separate names with a comma.