Red giants are formed when a smaller main sequence star runs out of fuel, cools and expands.
Smaller stars like our sun will form red giants in the future. A red giant then turns into a white dwarf and finally a black dwarf. Stars with more mass follw a different pathway - they will turn into a red supergiant.