How do we separate marginals from dependence using copulas, and why do we assume uniform marginals? I read that one advantage of using copula function is that, we can separate the marginals from dependence between variables. I tried to understand how we can do that but I could not find the answer. Is there any help?
Why do copula assume uniform marginal distributions?
Also, how can I transform the data to have uniform marginal distributions?
 A: I think your two questions are closely related. I will start with answering the second.
For any continuous random variable $X$ with CDF $F_X$, $F_X (X) \sim U[0,1] $, that is, it is uniformly distributed: this is called Probability integral transform and a simple proof is e.g. here. So transforming a continuous random variable to uniform is quite simple, if you know its CDF.
For copulas, there is some similarity. A joint c.d.f. $F$ of at (e.g.) two random variables, $X_1$ and $X_2$, can be denoted as $F(x_1, x_2)$. If the two RVs have c.d.f. $F_1$ and $F_2$, respectively, then $F(x_1, x_2)$ can be rewritten as $C(F_1(x_1), F_2(x_2))$. So it become a joint c.d.f. of two uniformly distributed random variables. Function denoted $C(,)$ is some copula.
The advantage is that in practice, it is often easier to estimate the distribution of the marginals than to make an estimate about the joint distribution. But with the copula theory, for every joint multivariate distribution, there exists a unique copula. For some copulas used often in practice (Gaussian e.g.), estimating their parameters is basically reduced to finding a correlation matrix of the RVs, so with known marginals, "reconstructing" the joint distribution is quie simple.
A: Often suitable models for the marginal distributions may already be available (whether because the variables are well-studied in this area, or because of facts known about the variable). Even in the absence of that, modelling univariate data is a reasonably straightforward task. Copulas allow you to "plug in" such understanding of the univariate variables.
Imagine you have a random sample from a bivariate continuous distribution (pairs $(x_i,y_i),\, i=1,2,...,n$).
You could choose a model for each variable on its own in some fashion.
The difficulty is then that you need a model for the multivariate structure that retains your univariate models. This is often tricky to do directly.
However, by transforming the margins to uniformity (and there are several senses in which that can operate in practice), you're left with identifying structure where the margins are always the same. 
What we really mean by "dependence structure" is consistently understood from problem to problem, and we can have a set of tools that always work in the same general same way, even as the specific dependences and the margins are different from problem to problem.
So for this problem of modelling dependence in data with uniform margins there's a large collection of suitable multivariate models, methods for making more, and methods for fitting them; we avoid the difficulty of having to come up with a new multivariate family every time we consider change to a marginal model.
As for why copulas use uniform margins rather than something else, its mostly a matter of convenience; if you want to separate modelling dependence from modelling margins you will want to convert to some standard distribution (otherwise the problems aren't really separated!), and one with uniform margins is both obvious (you've clearly "removed" all distributional shape from the marginal distribution in a direct way) and simple to do.
You could potentially transform to something else as the "standard" (e.g. to standard normal margins for example), but for most copulas it would not tend to make things simpler (quite the contrary).
