What are the origins of the window functions in DSP? Why not just use a rectangular window?
My confusion is arising from coming to know that the window function has its origins in the time domain 


This is correct. Normally when we talk about a window function we're talking about something that's applied in the time domain.


  and not the frequency domain and the window function is convolved in time with our main signal to filter it!


This is incorrect. The window function is not convolved with the input signal, it is multiplied by it. 

Convolving the window with the input would be equivalent to multiplying after doing the FFT (of both the window and the input sigal). This would be equivalent to what you describe in your first paragraph. But calculating it as a convolution in the time domain would require potentially much more computational effort than doing multiplication in the frequency domain. 


  I thought that the window function is something in the frequency domain that is multiplied by the frequency spectrum of our main signal that is being filtered.


If we multiply in the frequency domain, we don't usually call that a window function. We call it a filter.


  Why don't we do filtering in the frequency domain by taking FFT and multiplying it with a window and than doing inverse FFT?


We often do do filtering this way. But windowing is not the same as filtering. 
Filtering is equivalent to convolution in the time domain. 

But when we do windowing, we actually want multiplication in the time domain.


  I think this will not work very well since our main signal is not periodic (like speach) and we do not have ALL samples of it when we do the FFT


This is exactly why we use window functions. When we do a discrete Fourier transform (DFT), we assume we have sampled one or more periods of a periodic function. But, like you say, this is often a very poor assumption. 

The result is that our periodic-extended signal has large jumps where the last sample wraps around to the first sample. When we do the DFT, that big jump can be the dominant feature whose effects we see in the spectrum. But it's not at all what we want to study.

Typically our window function is "large" in the middle and "small" at the edges. This enhances the features we want to see in our samples and minimizes the effect of the jump between the last and the first sample. 

Of course we can also look at its effect in the frequency domain in terms of side lobes and so on, but as you say that is a bit hairy to get your head around.