The aspect that the other answers failed to emphasize were that there are quite many devices in modern windshields. For example, a modern windshield can be defrosted by using the integrated heating elements. Also, rain detectors allow variable wiper intervals. Furthermore, there may be a camera behind the windshield monitoring lane markers and speed limit traffic signs.
To install a replacement windshield, it obviously needs to be equivalent to the OEM windshield and thus have integrated heating elements, if the original windshield had these. Also, the camera may need to be calibrated and also the installation is otherwise a professional job so that rain detectors and heating elements work properly.
My current car (a 2016 Toyota RAV4) has all of these high-tech features. If my windshield ever breaks, I definitely will NOT get an aftermarket windshield or perform the installation at an independent garage. I will let the dealership replace the windshield with an OEM component, performing a professional job.
However, this answer doesn't apply to older cars that lack these advanced features. For older cars, aftermarket windshield might be an option worth considering.