With what we know today about ion charges, nomenclature rules and so on, writing chemical formulas is fairly routine. But where did formulas come from before all of that was figured out?
Early chemists spent a lot of time developing techniques to analyze substances, eventually arriving at data such as the number of grams of hydrogen and oxygen in a given mass of water. In percent form this information is called "percent composition by mass" or simply percent composition.
The calculation of % composition can be based on what we know today is the correct formula for water, H2O. The molar mass of water is 18.0 g/mol. Of that 18.0 g, 2.0 g are hydrogen and 16.0 g are oxygen. So the mass percents of each element could be expressed as: