It is arrived at through the scientific method, which involves
gathering and analyzing facts
formulating hypotheses to explain the phenomenon
testing the hypotheses
and finally proposing a theory.
The hypotheses is a tentative explanation.
A scientific theory is a testable explanation for some natural phenomenon, that is supported by a large body of evidence.