We don't know where quarks come from, anymore than we know where electrons come from. They are supplied by nature, as far as we know, as the basic elementary particles that the world around us is built upon. In the same way, we don't yet know why the speed of light is 300,000 m/s or what Dark Matter or Dark Energy are.
We have a theory, called the Standard Model, which is based on experimental evidence. In turn, the Standard Model is based around Quantum Field Theory, which provides theoretical predictions that we can test using instruments such as the LHC.
However, to make the Standard Model work, we have to simply accept the properties of around 20 parameters, such as the strength of interaction of photons with electrons. We have no real idea why these parameters have the values they do, we can only measure them and use them in our predictions.
From Wikipedia Strong Interaction
An animation of the nuclear force (or residual strong force) interaction between a proton and a neutron. The small colored double circles are gluons, which can be seen binding the proton and neutron together. These gluons also hold the quark-antiquark combination called the pion together, and thus help transmit a residual part of the strong force even between colorless hadrons.
Quarks use gluons, which are massless, to exchange the color force, which keeps 3 quarks together to form neutron and protons (baryons), and pions(mesons) use gluons to keep a quark and antiquark together. BUT, the force carried by gluons has a very short range, always staying inside baryons and mesons. The force between protons and neutrons, which keeps the nucleus together, is carried by mesons. If you read the above link
(slowly :) ) it will give you the full picture.