Louis XVII, born as Louis-Charles in 1785, was the second son and third child of Louis XVI and Marie-Antoinette. He became the Dauphin of France (heir apparent) after the death of his brother Louis Joseph in June 1789, but never ascended to the throne.
In 1792, France became a republic and Louis XVI was found guilty of high treason in a trial by the National Convention so was executed by guillotine in 1793. Meanwhile, Louis XVII was imprisoned for the remainder of his short life until death from illness in 1795.
Although he never ruled, Louis XVII was the legitimate bearer of his royal name because, according to monarchist theory, there is always a monarch and so upon the king’s death the heir apparent ascends.
When Louis XVII died his exiled uncle, Louis Stanislas Xavier, took the name Louis XVIII of France and claimed his rightful place on the throne after the defeat of Napoleon in 1814. Therefore, in order of ruling French monarchs, Louis XVIII followed Louis XVI, and not Louis XVII.