What does it mean when two functions are "orthogonal", why is it important? I have often come across the concept of orthogonality and orthogonal functions e.g in fourier series the basis functions are cos and sine, and they are orthogonal. For vectors being orthogonal means that they are actually perpendicular such that their dot product is zero. However, I am not sure how sine and cosine are actually orthogonal. They are 90 out of phase, but there must be a different reason why they are considered orthogonal. What is that reason? Does being orthognal really have something to do with geometry i.e 90 degree angels?

Why do we want to have orthogonal things so often in maths? especially with transforms like fourier transform, we want to have orthogonal basis. What does that even mean? Is there something magical about things being orthogonal?
The concept of orthogonality with regards to functions is like a more general way of talking about orthogonality with regards to vectors. Orthogonal vectors are geometrically perpendicular because their dot product is equal to zero. When you take the dot product of two vectors you multiply their entries and add them together; but if you wanted to take the "dot" or inner product of two functions, you would treat them as though they were vectors with infinitely many entries and  taking the dot product would become multiplying the functions together and then integrating over some interval. It turns out that for the inner product (for arbitrary real number L) $$\langle f,g\rangle = \frac{1}{L}\int_{-L}^Lf(x)g(x)dx$$ the functions $\sin(\frac{n\pi x}{L})$ and $\cos(\frac{n\pi x}{L})$ with natural numbers n form an orthogonal basis. That is $\langle \sin(\frac{n\pi x}{L}),\sin(\frac{m\pi x}{L})\rangle = 0$ if $m \neq n$ and equals $1$ otherwise (the same goes for Cosine). So that when you express a function with a Fourier series you are actually performing the Gram-Schimdt process, by projecting a function onto a basis of Sine and Cosine functions. I hope this answers your question!
Here is a way to consider it, for what it's worth.  Plot f and g on separate sheets of paper. For convenience, put the sheet with the graph of f horizontally and the sheet with the graph of g vertically (at a 90 degree angle) to the other sheet.  Take a value of x, and for simplicity, assume that f(x) is positive.  So, you can point your right thumb from the x axis out to f(x).  If g(x) is also positive, you can point your right index finger up to it.  In such a case, the cross product of f(x) and g(x) points in the direction of the third finger of your right hand towards you.  If f(x) is positive but g(x) is negative, then the third finger of your right hand points away from you.  Or, in other words, f(x), g(x), and f(x) cross g(x) form a left-handed system at that x.  Now integrate over the region.  If f, g, and f cross g "on average" (bearing in mind that the magnitude of f(x) cross g(x) is f(x) times g(x)) are left handed just as much as they are right handed, then f and g are orthogonal.  I hope this makes sense.  You might try visualizing it with sine and cosine for a specific example.