Rabbi means "great one" in Hebrew, or "respected one", like Arabic rabb, meaning "lord." It showed respect, like calling someone "Sir". In early Jewish history, there were no rabbis, only priests in the temple who organized ceremonies and sacrifices. Around 50 AD, people began to call wise men like Gamaliel by the title Rav or Rabban, to show that they were leaders and teachers. Just a little later, Matthew, Mark, Luke and John used the same word as a title for Jesus in the Gospels.
In 70 AD, when the Roman general Titus destroyed the temple in Jerusalem, the Jews stopped offering sacrifices to their god, and stopped having priests. Instead, rabbis, or teachers, became their religious leaders, at least until the temple is rebuilt. During the time of the Roman Empire, you became a rabbi by studying the Torah (the Bible) and then getting smicha (being ordained) by the council of the Sanhedrin, who were in charge of Jewish religious business.
In 425 AD, the Roman empress Pulcheria ended the Sanhedrin, because she wanted everyone to be Christians. After that, you became a rabbi by studying and then getting smicha from the rabbi who had been your teacher. Some famous rabbis of the Middle Ages were Maimonides, who lived in Cairo, in Egypt, and Rashi, who lived in France.