Why the Spanish built the missions and the purpose of the missions.
The missions were built by the Spanish starting in 1769 in order to "colonize" the territory of Alta California, which they had discovered over two centuries earlier. There had been various proposals over the years to do something with this territory, but it was hard reaching the coast of Alta California from New Spain (Mexico) in those days, sailing against the wind and currents, and Spain had other priorities. What finally moved them to act was the fact that Russian fur trappers were moving farther and farther down the Coast (from their bases in Alaska) and were spotted near present day San Francisco in 1760s.
You might ask why they didn't send settlers. They did send a few, but not very many people wanted to go to this "wilderness." The Spanish also had good results previously using missions to settle other parts of their frontier-in Arizona and Texas, for example, and in the Rio de la Plata region of Latin America.
The mission system required that Indians brought into a mission be baptized into the faith and "civilized." This was considered another big plus supporting the use missions as the central element in colonization.
Ultimately, the Spanish built several pueblos (towns), the largest of which became Los Angeles. Almost ten of the original missions had towns grow up around the mission.