Significance of Codomain of a Function We know that Range of a function is a set off all values a function will output.
While Codomain is defined as "a set that includes all the possible values of a given function."
By knowing the the range we can gain some insights about the graph and shape of the functions. For example consider $$f(x)=e^x$$By knowing that the range of the function is $(0,\infty)$,we can conclude that the graph lies above the $X-axis$.
My Questions

Does knowing codomain of a function give any insight/information about the function?
Every function has a specific range and it is universal? Is it true for codomain also?
What I am trying to say is that range of $\sin x$ is $[-1,1]$.While as per my understanding codomain is $\mathbb R$ (Real Numbers).But defining codomain of $\sin x$ as say $(-2,2)$ is not going to change anything. So $(-2,2)$ is a valid codomain for $\sin x$. Am I right?
What compelled mathematicians to define codomain, why were they not happy with the concept of range only?

 A: 
What I am trying to say is that range of $\sin x$ is $(-1,1)$.

You made a mistake here. The range of sine is a closed interval, which we denote with $[-1, 1]$, not an open one $(-1,1)$.

While as per my understanding codomain is $\Re$(real numbers).

Yup, real numbers. But they are usualy denoted with $\mathbb R$ (LaTeX/MathJax \mathbb R), not $\Re$ (\Re).

But defining codomain of $\sin x$ as say $(-2,2)$ is not going to change anything.

You're wrong. Redefining the codomain may change properties of a function. Giving the sine function a codomain of $(-2,2)$ doesn't change it much, but giving it $[-1,1]$ changes a lot:
$$\sin : \mathbb R \to [-1,1]$$
is a surjection (a function "onto"), while
$$\sin : \mathbb R \to \mathbb R$$
is not.
Redefining a domain may change the function's properties, too:
$$\sin : \left[0, \tfrac\pi 2\right] \to \mathbb R$$
is an injection (a function "into"), while
$$\sin : \left[0, \pi\right] \to \mathbb R$$
is not.
To answer specifically the last sentence from the question:

What compelled mathematicians to define codomain why were they not happy with the concept of range only.

Here I copy what I previously added in the comment below:
we need codomains, because we sometimes need to consider functions, whose definition is known together with a codomain, but the range is unknown. Sometimes we do not even have the definition, only some properties are known and we are satisfied with knowing the codomain without narrowing it to the range ("suppose $f$ is a real-valued function such that...; show $f$ is constant" – we know the codomain is $\mathbb R$ and we just need to show the range is one-point, not necessarily which one).
Expansion:
Be also aware that the range of a function may be hard to describe. For continuous real functions we consider at schools the range is often an interval or a sum of intervals – but those are special cases. There are functions with much less  regular ranges.
For example see this question at Math.SE: Show that the function f is continuous only at the irrational points for a function described also at Wikipedia: Thomae's function – it is defined on real numbers, but its range is a set of reciprocals of all natural numbers and zero: $$\mathbb R \to \{\tfrac 1n:n\in\mathbb N\}\cup\{0\}.$$
One can easily declare a function whose range is literally any predefined nonempty set $S\subseteq\mathbb R$ – just choose any $s\in S$ and define: $$f:x\mapsto \begin{cases}x&\text{if }x\in S,\\s&\text{otherwise.}\end{cases}$$
In more general approach the range can be even harder to describe analytically.
Consider a function, whose parameter is real and values are pairs of real numbers (or complex numbers, which is equivalent to latter thanks to the complex plane by Jean-Robert Argand). If the function is continuous, its range is a curve on a plane. For example if the function is a position of a projectile in terms of a height and a distance, we get a complete trajectory. It's not too likely one will need to compare such trajectories – we will usually be interested in the maximum height and a maximum distance reachable under some conditions, but not the whole shape. Anyway, it is possible. But how would you compare a curve of a ballistic trajectory to a simple square? ...to a Koch snowflake? ...to the Warsaw Circle? ...or to a Heighway dragon?
And how about non-continuous functions, or those defined on some subsets of $\mathbb R$, whose ranges may become any figure on the plane, for example a family of concentric circles intersected by a family of parallel lines? ...or the interior of an annulus?
Things get even more weird if the 'target space' of a function is some more complex set, like a space of integer sequences, a space of real matrices $5\times 5$, a space of real functions integrable over a unit interval, and so on. You don't always need to know the range of a function, often it's just enough to know what its codomain is.
A: Note: This is the informal, high-school to early college answer.  The formal answer, given by @zkutch, is better for a thorough understanding.
The codomain is useful for bounding the range when the exact range is not computable or at least not easy to figure out.  So it is the superset of the range.
Taking $\sin(x)$ as your example, the distinction isn't super relevant but only because we know so much about that function.  First we know that it achieves an exact minimum (-1) and an exact maximum (+1) and that it is continuous.  We have theorems (specifically the Intermediate Value Theorem) that tell us that the function must attain every value between those two, since it is continuous.  As a result, the range is exactly specified.
Now, what about a more complicated function, or one where it is not clear whether it is continuous or not?  Or one where it doesn't actually reach a particular value?  A simple example might be:
$$f(x) = \frac{1}{x}$$
We know that $f(x) \ne 0$ for any $x$.  So the range is not easy to specify.  We'd need an open set.  Perhaps we want to avoid that, so we'd specify the codomain as $x \in \mathbb{R} | x \ge 0$ and now we get a closed set.  There are other examples that I can't immediately think of where figuring out the codomain is much easier than the range.
We might care because we may have a theorem that states "as long as the range doesn't go positive, we are OK".  We may not know the exact range, but we do know that the codomain is the set of all negative real numbers, so we have no issues. (This is a very vague expression of a result from control theory, where the poles of a linear time invariant system must have negative real parts for system stability.  The pole locations are based on factoring polynomials, which is hard or impossible, but we may be able to bound their locations quite easily).
The codomain, as you saw, was not unique, so no, there is no "universal" codomain for your function.
A: Generally function $f=(F,A,B)$ is defined by triple, where $A$, $B$ are sets, $F$ is functional graph and domain $pr_1F=A$ as it is in "Theory of Sets" N. Bourbaki. So you can consider different triples and obtain different functions.
Let's denote, for example, by SIN graph for $\sin$. Then
$$(\text{SIN},\mathbb{R}, [-1, 1])$$
$$(\text{SIN},\mathbb{R},[-2,2])$$
Are formally different functions.
