If you look at the night sky with a small telescope you will notice that some stars are actually double stars. Some of these, such as Mizar and Alcor in the big dipper, are simply two separate stars that happen to be in the same direction. Most, however, are binary stars that orbit each other.
The first known binary stars were observed in the 1800s, but it wasn’t until the 1900s with the introduction of the filar micrometer that decently accurate measurements could be made. This device allowed you to center your telescope on the primary star, and then measure the position of the secondary star relative to the primary. By taking measurements over time (sometimes years or decades) you can start to see the companion star trace its path. In the figure below, I’ve plotted observations of the star Xi Ursae Majoris.
The good news is that the motion of a binary companion is an ellipse, so with a bit of mathematics you can fit your observation to an elliptical path. The bad news is that the positions we observe are within the plane of our field of view. The actual orbit is usually tilted relative to us, so we have to do more math to determine its actual orbit. In times past, this had to be done by hand and was really laborious. With modern computers, we can fit the data and calculate orbits pretty easily.
Of course, if you know the orbit of the companion star, you can also calculate their masses. Knowing their separation distance and orbital period, you can calculate their masses via Kepler’s laws. Once we’ve determined their masses, we can look at other properties such as their brightness and temperature to see how they correlate to mass.
Turns out you can learn a lot from stars by looking at their mutual attraction.