What exactly is a cokernel? What's the motivation behind that, and what's its use? And why is it a quotient module? Having a homomorphism of $R$-modules $f\colon M \rightarrow N$, we say a cokernel is $N/(\operatorname{im} f)$ which is a $R$-module (quotient).
Because $\operatorname{im} f\subset N$, this would mean that $\operatorname{im} f$ is an ideal.
So why is it an ideal?
Also, why do we even bother defining something like a cokernel? What's its use, what's the motivation behind a cokernel?
 A: First off, $\operatorname{im}f$ is not an ideal but a submodule as $M$ and $N$ are $R$-modules and not rings. As you might recall the image of a ring homomorphism is not necessarily an ideal of the codomain as there is no reason for the image being closed under multiplication from the codomain.

As hinted in the comments the cokernel is fundamentally related to the notion of a kernel. For a more direct interpretation of this analogy we note the following proposition(s).

Fact. Let $M,N$ be $R$-modules and $f\colon M\to N$ be a $R$-module homomorphism. $f$ is injective iff $\ker f=0$. $f$ is surjective iff $\operatorname{coker}f=0$.

I suppose you know the injectivitiy part and the surjectivity part is not that hard to prove either (I would advise you doing so if you haven't already). The crucial thing is that the quotient $N/\operatorname{im} f$ measures how far away $f$ is from being surjective in the same way the kernel measures how far away $f$ is from being injective. And this measurement can be best carried out in quotient form.
However, this quotient is not necessarily the definition of the cokernel. On a more abstract level many algebraic construction may be characterized by certain universal properties. Among those constructions are the kernel and the cokernel. These are related to annihilation of elements in a certain sense.
So consider $f\colon M\to N$ as before. Now take $\alpha\colon K\to M$ and $\beta\colon N\to L$ not arbitrary but such that $f\circ\alpha=0$ (i.e. the image of $\alpha$ is annihilated under $f$) and such that $\beta\circ f=0$ (i.e. the image of $f$ is annihilated under $\beta$). Here $0$ denotes the trivial map sending everything to $0$.
The kernel is then characterized as pair $(\ker f,\iota\colon\ker f\to M)$ so that for any such $\alpha$ there is unique $\overline\alpha\colon K\to\ker f$ with $\iota\circ\overline\alpha=\alpha$. The cokernel on the other hand is a pair $(\operatorname{coker}f,\pi\colon M\to\operatorname{coker}f)$ so that there is an unique $\overline\beta\colon\operatorname{coker}f\to L$ with $\overline\beta\circ\pi=\beta$.
In both cases, any homomorphism with a certain property factors uniquely through these objects. And both definitions share this common core but are somehow mirrored (the word "dual" appeared in the comments). Interestingly enough: kernel and cokernel are uniquely up to unique isomorphism charaterized by these definitions (called universal properties). So they really capture the essence of these objects.
One can show that these charaterizations correspond to our usual definition of kernel and we can show that the cokernel of $f$ is simply the quotient module $N/\operatorname{im}f$! Indeed, take $\beta$ as above at note that $\beta\circ f=0$ implies that $\operatorname{im}f\subseteq\ker\beta$. By the homomorphism theorem this implies that there is a $\overline\beta\colon N/\operatorname{im}f\to L$ so that $\overline\beta\circ\pi=\beta$, where $\pi$ is the usual projection. Moreover, this $\overline\beta$ is unique (the homomorphism theroem really is just another universal property; namely, the one of the quotient). So our quotient really is the cokernel in this more abstract setting.
On a final note: The defining universal property only tells you what an object should do if it actually exists. The quotient construction only works well as $R$-modules always admit quotients. This thing becomes more complicated when considering the case of groups as the image of group homomorphism is not necessarily a normal subgroup and hence the quotient might not be defined to begin with. Cokernels, however, do exists for groups but are defined explictly constructed slightly different (Hint: Is there a way of extending the image until the resulting subgroup is normal; and what does this imply for the ability of cokernels to detect surjectivity?).
