I was recently learning about OpenGL and computer graphics development. I have a question regarding the usage of triangle as the basic building block, or basic shape to develop complex shapes. Is there a particular reason? Or just something that "stuck"?
Triangles are always flat, unlike a quad which can be made in a way that is bent / not all vertices on the same plane.
If you were to interpolate say vertex normals across each scanline, on a 4-edge bent quad it will render with horizontal (scanline) artefacts. If you made that same bent quad out of triangles, it will render correctly as each triangle has a different normal slope.
That's one reason why triangles are preferable for scanline rasterising
In computer graphics, people are interested in modelling the surface of the objects. And, since we are in the discrete world of computers, we need a discrete representation for surfaces, where we can easily check for stuff like intersections and angles, both vital for rendering.
The triangle makes it very easy to compute intersections and surface normals, but also has some useful features: it is always convex (if not degenerate), which means that the mathematics is a lot simplified. Being so basic, you can also split pretty much any shape in triangles.
But keep in mind that there are other basic shapes. Some hardware supports quads or nurbs, although it's much less common.