How do you find the metric tensor for a given manifold? Is there some general way to derive the metric tensor for a given manifold M? For example, how was the metric for the surface of a sphere $$ds^2=d\theta^2+\sin^2\theta \, d\phi^2$$ first derived? 
 A: This depends on how the manifold is defined. In general a metric is a symmetric bilinear form on the tangent space of a manifold $M$, that is you have, in each point $p$ of $M$, a scalar product which maps pairs of tangent vectors to real numbers:
$$X_p,Y_p\mapsto g_M(p)(X_p, Y_p) \in \mathbb{R}$$
For a Riemannian metric you require this to be a scalar product for each $p$.
If $M$ happens to be a submanifold of Euclidean space then this ambient space induces a metric on $M$, because you can identify vectors tangent to $M$ with vectors in the ambient space and just use the metric from the ambient space to calculate the value of the sclar product in a point for two tangent vectors. 
What you are referring to in your example is a particular representation of the metric. If you happen to have a local parametrization $$\phi:\mathbb{R}^k \rightarrow M$$ then the differential of this map maps tangent vectors of $\mathbb{R}^k$ (often denoted by $\frac{\partial}{\partial x^i}$) to tangent vectors $\phi_* \frac{\partial}{\partial x^i}$ of $M$, for which you can now calculate the scalar product 
$$g_{ij} = g_M(\phi_* \frac{\partial}{\partial x^i},\phi_* \frac{\partial}{\partial x^j})$$
The tensor $g_{ij}$ is now just the matrix representation of the metric in the given coordinates. The metric tensor itself is then often written as $g_{ij}dx^i\otimes dx^j$. This tensor will be diagonal in case the tangent vectors associated with the coordinte system form an orthogonal base, which is what happens in your example as well (you will need to know the actual map from $\theta,\phi$ space to the sphere to calculate it explitly). 
A: Your question is more precisely: Given a Riemannian manifold (=already equipped with a metric), how does one compute the metric data in a certain local parameterization.
Now, let me show how I computed this for sphere.
I take the rectangle of sides $2\pi \times\pi$ in $R^2$, and forget about its plane metric. I want to impose a new metric on it, so that it will become the sphere. (No, truly and genuinely a sphere!) Also, keep in mind that the two vertical sides will be identified, and each of the horizontal sides will be crushed into one single point, giving North and South poles. But, focus on what I do in the interior for a moment. (Square is $(\phi,\theta)$ pairs.)
I think of each vertical line as one meridian. They should each map to a meridian join north pole to the south pole, thus having the same geometry (local length, and stuff) all along the way. So, my choice of side of $\pi$ lets me retain the Euclidean lengths of vertical lines.
However, fix a $\theta$, and look at the horizontal line joining them. It maps to horizontal circles on the sphere. But they are not the same sizes. The middle line goes to the equator of the sphere, hence having the biggest length of $2\pi$. The higher/lower you go, circles become smaller, with smaller perimeters. When you reach the sides, you've shrunk to the north/south poles, so a circle of zero perimeter. Also notice that the sizes of circles only depends on $\theta$ (vertical position) and not on $\phi$.
If you draw a picture of the sphere, and do some trigonometry, you will see that the radius of a horizontal circle at angle $\theta$ is $\sin^2(\theta)$. This means that when $d\phi$ travels a full horizontal line, it will have traveled the perimeter $2 \pi sin^2\theta$ of the circle.
See that this agrees with $\theta =0,\pi$ mapping to zero lengths, and $\theta =\pi/2$ mapping to the largest circle with $2 \pi$ length.
Sorry, I am not good with shapes in computers, but please do draw some to see for yourself. They are a great way of learning thee stuff.
Another way of looking at this is saying that: If I declare the usual $i$ and $j$ vectors of $R^2$ not to have unit length everywhere, but for $i$ to have length $sin^2y$ if it has its initial point at $(x,y)$, ($j$ still enjoys a unit length everywhere!) then the resulting metric manifold is isometric to the sphere.
