The relation between momentum and kinetic energy for a single particle:
Momentum is defined as:
$$\vec{p} = m \vec{v}$$
So, we can write velocity as:
$$ \frac{\vec{p}}{m} = \vec{v}$$
Kinetic energy is defined as:
$$ K = \frac{1}{2} mv^2$$
Using the previous equation,
$$ K = \frac{p^2}{2m}$$
So, it's very easy to see that it can be said that kinetic energy is a function of momentum and mass for a single particle.
In an inelastic collision, the momentum is conserved but the kinetic energy is not. You may think otherwise from the previous equation I wrote because it says that kinetic energy is a direct function of momentum.
When we have a collision what happens is the total momentum is split up between the different bodies such that if we summed momentum of every single body then the total momentum is the same.
The simple idea is that in an inelastic collision, the total momentum redistributes among the objects of collision in a way that when you take the difference of kinetic energy between the final and initial state, it gives a negative number. The lost energy goes into heat and vibrational energy.
Example:
Consider two clay balls body $A$ and $B$ with the same mass m. Each momentum velocity $v$ and collide head-on undergoing inelastic collision. Let velocity after collision be $v'$
The initial kinetic energy is:
$$ K = \frac{mv^2}{2} + \frac{mv^2}{2} = mv^2$$
Now after collision, they become one body with a velocity of zero (Refer). By momentum conservation for before and after collision:
$$ mv - mv = (m+m) v'$$
Hence,
$$ v'=0$$
Putting this into the kinetic energy post-collision is:
$$ K' = \frac{ (2m) (0)^2}{2} = 0$$
So we can see that the kinetic energy $ mv^2$ was lost completely. This energy went into deforming the clay and vibrational energies as Feynman has said in a quote that I put in the references (*).
The heart of the matter is that for an individual particle, we can relate it's kinetic energy and momentum but for a system of particles the two are not directly related.
Derivation the loss in energy:
Let two bodies $A$ and $B$ with mass $m_a$ and $m_b$ respectively. Let their initial momentums be $\vec{p_a} $ and $ \vec{p_b}$ and after collision in which they stick let their momentum be $\vec{p_{ab}}$ then their loss in kinetic energy.
$$K_{i} = \frac{ (\vec{p_a})^2}{2m_a} + \frac{ (\vec{p_b})^2}{2m_b}$$
The final kinetic energy is given as:
$$ K_{f} = \frac{ (\vec{p_a} +\vec{p_b})^2}{2(m_b +m_a)}$$
Note the momentum in the final must be equal to the initial momentum of $p_a +p_b$ due to the momentum conservation.
Hence,
$$ K_f = \frac{ (\vec{p_a})^2 + ( \vec{p_b})^2 + 2 \vec{p_a} \cdot \vec{p_b}}{2(m_b +m_a)}$$
Now consider the difference of kinetic energy between final and initial states:
$$ K_f - K_i = \frac{ \vec{p_a} \cdot \vec{p_b} }{m_a + m_b} - [ \frac{(m_a \vec{p_b})^2 + (m_b \vec{p_a})^2}{2(m_a + m_b)(m_a m_b)}]$$
$$ K_f - K_i =-\bigg[ \frac{(m_a \vec{p_b})^2 + (m_b \vec{p_a})^2 - 2m_a m_b \vec{p_a} \cdot \vec{p_b}}{2(m_a + m_b)(m_a m_b)} \bigg]$$
Or,
$$ K_f -K_i = - \bigg[ \frac{|m_a \vec{p_b} - m_b \vec{p_a}|^2}{2(m_a + m_b)(m_a m_b)} \bigg] $$
Since $m_a m_b$ is a strictly positive quantity, we can move it into the modulus :
$$ K_f - K_i =\frac{m_a m_b}{2(m_a +m_b)} (|\frac{\vec{p_b}}{m_b} - \frac{\vec{p_a}}{m_a}|)^2$$
Since we can switch terms in the square modulus,
$$ K_f -K_i = \frac{m_a m_b}{2(m_a +m_b)} (|\frac{\vec{p_a}}{m_a} - \frac{\vec{p_b}}{m_b}|)^2$$
Now, we can say that kinetic energy change has been reduced in the final state. This absolute value of the amount which is lost is taken as $K_{loss}$ and is given as:
$$ K_{loss} = \frac{m_a m_b}{2(m_a +m_b)} (|\frac{p_a}{m_a} - \frac{p_b}{m_b}|)^2$$
q.e.d
Further reading:
HC-Verma: Concept's of Physics
Feynman lectures (under energy and momentum of chapter-10)
To understand these ideas in more depth, see the answer by Ron Maimon here