Hello!
Sometimes when there are outliers in a data set, for example 1, 20,25,26,30, one is the outlier and when you find the mean it will not represent the data in the most accurate way. This is when you use the median to represent the part of the data set that has the information that is close together.
I hope this helps!