Secondary structure is formed mainly as a result of hydrogen bonding between the carboxyl group of one amino acid and the amino group of another amino acid, forming alpha helices and beta-pleated sheets. There are other types of folds, but they aren't that common.
"Different amino-acid sequences have different propensities for forming α-helical structure. Methionine, alanine, leucine, glutamate, and lysine uncharged ("MALEK" in the amino-acid 1-letter codes) all have especially high helix-forming propensities, whereas proline and glycine have poor helix-forming propensities. Proline either breaks or kinks a helix, both because it cannot donate an amide hydrogen bond (having no amide hydrogen), and also because its sidechain interferes sterically with the backbone of the preceding turn – inside a helix, this forces a bend of about 30° in the helix's axis. However, proline is often seen as the first residue of a helix, it is presumed due to its structural rigidity. At the other extreme, glycine also tends to disrupt helices because its high conformational flexibility makes it entropically expensive to adopt the relatively constrained α-helical structure."
According to wikipedia, the propensity for alpha helices to form is dependent on the sequence of amino acids, as some have more free energy on their residues than others (less free energy = higher likelihood to form an alpha helix). I assume this is similar in regard to beta-pleated sheets, but you can look that up yourself if you are interested :)
In general, secondary structure is dependent on primary structure because some sequences and individual amino acids have a higher propensity to form alpha helices and beta-pleated sheets, which can be measured by the amount of free energy available on the residues of those specific amino acids.