In general, things move slower as they get further from the center of an object. For a galaxy, scientists predicted that stars would rotate slower as they get further from the center just like other objects. However, what they observed was that the outer stars move as fast as inner stars. Since mass of an object is related to its velocity by Kepler's third law (v2 = GM / r), scientists concluded that in order for that to happen, there must be something invisible with a large mass surrounding galaxies.
Gravitational lensing is a bending effect of light caused by something with large mass. The Bullet Cluster (image on the left) is the most commonly used example.Using gravitational lensing, scientists discovered that sometimes there is more mass in the area we don't see. Bullet cluster is a good example. When you look at the image, there are two pink galaxy clusters in the middle. There is no other object that is visible by eye. However, scientists actually found out through gravitational lensing analysis that there is more mass in the blue area, which is not visible to us. There has to be something with a large mass in order for that to happen. Since we know that there is something in that blue area, but we don't see anything, we call it "dark matter".
When assumed that a galaxy cluster is in the state of equilibrium, meaning that galaxies orbit around each other instead of getting closer, the mass of the galaxy cluster can be discovered by using the velocity of the galaxies. Scientists discovered that the mass of the galaxy cluster should be larger than what's visible for it to be stable. That excess is attributed to dark matter.