A simple word search for "baptism" in the Old Testament turns up no matches. However by the time John the Baptist shows up on the scene and starts dunking people "for forgiveness of sins" (Mark 1:4) people seem to already have an understanding of what baptism is.
It seems there were actually others performing baptisms during and even prior to John and Jesus. In fact, nobody seems be too concerned about the act itself -- as if it was a well understood practice already. The question that continually comes up instead is "by whose authority?" (Matthew 21:25, Mark 11:30, Luke 7:29, Luke 20:4) So what is the context into which Jesus and John's baptisms began?
Torah (Old Testament)
The Law of Moses required ablutions (washings) on the part of priests following certain sacrifices and on certain individuals who were unclean because of an infectious disease (Num. 19:1-22; Lev 14,15, 16:24-28). The natural method of cleansing the body by washing and bathing in water was always customary in Israel. The washing of their clothes was an important means of sanctification imposed on the Israelites even before the law was given a Mt. Sinai (Ex 19:10). The use of water for cleansing was used symbolically as well in such passages as Ezekiel 36:25 where God says, "I will sprinkle clean water on you, and you will be clean; I will cleanse you from all your impurities . . ."
Intertestamental period (between Old Testament and New Testament)
Along with the purposes already mentioned in the Torah, another use of symbolic purification by water became part of early Jewish tradition. This was immersion or baptism for Gentile converts to Judaism. Though the only Biblical requirement for entrance into the covenant was circumcision, baptism became an added requisite. No one knows exactly when or by whom the requirements were changed to include baptism, but it was before the time of Jesus. We know this because debates on the subject of proselyte baptism are recorded between rabbinic schools. To this day, Gentiles who would embrace Judaism must undergo baptism in a mikveh ritual. The purpose of this ceremonial immersion is to portray spiritual cleansing.
Not just baptism
So John and Jesus basically borrowed and repurposed a practice that was already commonplace in first-century Judaism and simply imbued it with new and deeper spiritual meaning. Not that this should surprise us. Jesus did the same thing with the Passover meal (Matt 26:17-29) when he instituted communion and presented himself as the true Passover lamb (1st Cor. 5:7).
But lest you think Christianity is getting all the holey hand-me-downs from Judaism with a little Jesus-patch sewn to the knees, the reality is quite the opposite. In the Passover and in the Old Testament types of baptism, we see rituals that had to be endlessly repeated (quite literally, "wash, rinse, repeat"). But now we understand that these were just foreshadowings of the perfect Passover lamb—and the perfect baptism—in Christ that would be once and for all.