When can a given element in a monoid be decomposed into the product of a given element and another element? Let me begin with the particular monoid that I was origionally interested in, which was the set of real valued functions of a single real variable with the composition operation. My question was this, given functions $f$ and $g$, when can we find $h$ such that $f = hg$? Now clearly if $g$ is invertible, then putting $h = fg^{-1}$ works. However, even where $g$ is not invertible, we can still sometimes find $h$. For example, with $f(x) = 2x^{2}$ and $g(x) = x^{2}$, we can set $h(x) = 2x$. A little more thought shows that if $g(x_{1}) = g(x_{2})$, then $f$ must likewise take on the same values at $x_{1}$ and $x_{2}$ if we are to find an $h$. Is this condition also sufficient? This all feels a bit messy and specific though. So here is my question:
Let (M,*) be a monoid. Let $a,b \in M$, with b non invertible. Can we say anything at all about when there will exist $c \in M$ such that a = cb ?
 A: Let me answer your question in two steps. 
Step one. The $\leqslant_\mathcal{L}$-preorder.
Let $M$ be a monoid. The notion you define is a relation (due to Green) known as the $\leqslant_\mathcal{L}$-preorder. It can be defined as follows: 

$x \leqslant_\mathcal{L} y \iff Mx \subseteq My$.

This means that the left ideal generated by $x$ is contained in the left ideal generated by $y$. Equivalently

$x \leqslant_\mathcal{L} y \iff {}$there exists $z \in M$ such that $x = zy$.

The preorder $\leqslant_\mathcal{L}$ can be defined on any semigroup $S$. Let us denote by $S^1$ the monoid equal to $S$ if $S$ is a monoid and equal to $S \cup \{1\}$, where $1$ is an identity for $S$, 
if $S$ is not a monoid. Then the definition is modified as follows

$x \leqslant_\mathcal{L} y \iff S^1x \subseteq S^1y \iff {}$ there exists $z \in S^1$ such that $x = zy$.

The preorder $\leqslant_\mathcal{L}$ is part of the Green's relations, which are thoroughly studied in any textbook on semigroup theory.
Step two. What can be said about the $\leqslant_\mathcal{L}$-preorder?
Consider the case you are interested in, or more generally the monoid $T(X)$ of all functions from a set $X$ to itself, under composition. Given $f \in T(X)$, let 
$$
\ker(f) = \{(x,y) \in X^2 \mid f(x) = f(y) \}
$$
I claim that 

$f \leqslant_\mathcal{L} g$ if and only if $\ker(g) \subseteq \ker(f)$. 

Indeed, if $f = h \circ g$ and $g(x) = g(y)$, then $f(x) = f(y)$. For the opposite direction, it suffices to adapt your argument as follows: if $\ker(g) \subseteq \ker(f)$, then the relation $h = f \circ g^{-1}$ is actually a function such that $f = h \circ g$.
Since any monoid $M$ is isomorphic to a submonoid of $T(M)$, it is tempting to generalize this result to arbitrary monoids, which leads to the following question: if $S$ is a subsemigroup of $T$, what are the connections between the preorders $\leqslant_\mathcal{L}$ on $S$ and on $T$? Let me indicate a partial result in this direction:

Let $T$ be a subsemigroup of a semigroup $S$ and let $s, t \in T$ with
  $t$ regular in $T$. If $s \leqslant_\mathcal{L} t$ in $S$, then $s \leqslant_\mathcal{L} t$ in $T$.

A similar result holds without any regularity assumption in two cases: when $S$ is an ideal of $T$ and when $S$ is a local subsemigroup of $T$.

Let $T$ be an ideal of a semigroup $S$ and let $s, t \in T$. If $s \leqslant_\mathcal{L} t$ in $S$, then $s \leqslant_\mathcal{L} t$ in $T$. 
Let $e$ be an idempotent of a semigroup $S$ and let $T = eSe$. If two
  elements $s$ and $t$ of $T$ satisfy $s \leqslant_\mathcal{L} t$ in
  $S$, then $s \leqslant_\mathcal{L} t$ in $T$.

