Stars are primarily composed of hydrogen and helium because these elements were the most abundant in the early universe. Heavier elements are formed through nuclear fusion within stars and are released into the interstellar medium during supernova explosions. The processes for creating elements heavier than iron include the s-process, which occurs in red giants, and the r-process, which takes place during supernovae. The sun, being a smaller star, can only produce elements up to carbon and oxygen, while heavier elements like iron and nickel require more massive stars. Understanding these processes is crucial for grasping the origins of the elements found in the universe today.