What is the function of tosylchloride in the synthesis of an ether?
There are probably only two principal mechanisms in organic chemistry, one being electrocyclic reactions (not applicable here) and one being nucleophile/electrophile reactions. In the latter, which is what is happening in your case, you must always look for the group with either the highest electron density or the ‘best’ (I know, a hand-wavery term) nucleophilic properties — this group is the electrophile — and for the group with the lowest electron density or the ‘best’ (same hand-waveryness) electrophilic properties — termed the nucleophile.[1]

The first step to determining this would be to check electronegativities and oxidation states. Groups with high electronegativities and low oxidation states are typically nucleophiles and vice-versa. In your example, all alcoholic oxygens have a much higher electronegativity than all atoms they are connected to (carbon and hydrogen), are in the $\mathrm{-II}$ oxidation state and would thus act as nucleophiles. The oxygens and the chloride of tosyl chloride also have a larger electron density than their surroundings. For reasons outlined above that I cannot go into details with, they will not react nucleophilically, though.

The carbon atoms which are directly attached to the alcoholic oxygens all lack electron density due to the neighboring electronegative oxygen. They are electrophiles. And also the central sulfur of tosyl chloride — which not only features a $\mathrm{+VI}$ oxidation state but should also be drawn with a double positive formal charge to satisfy the octet rule[2] — is an electrophile.

To synthesise the ether from the two alcohols, we would now somehow need either of the two alcoholic nucleophiles to attack the other carbon electrophile and displace the other alcoholic hydroxy group — this reaction is termed $\mathrm{S_N2}$ reaction or bimolecular nucleophilic substitution. However, it is not likely to occur directly: a direct side-product would be the removal of a hydroxide ion, which is termed a bad leaving group.[3] We need to turn it into a better leaving group.

This is where tosyl chloride comes in. But first another little excursion: Notice the little 1. and 2. in your reaction scheme? They stand for first and second, implying that we are dealing with two separate reactions interceded by a workup and typically purification of an intermediate. So first we react the 1-phenylpropan-2-ol with tosyl chloride, collect the product and then react said product with ethanol. As I outlined before, a pretty good electrophile in tosyl chloride is the sulfur atom, and with the adjacent chloride, we have a good leaving group. So under a nucleophilic substitution,[4] this chloride can be displaced (along with a proton) leading to our intermediate 1-phenylprop-2-yl tosylate.

Technically we would now need to make a fresh analysis of nucleophiles and electrophiles. But it may suffice to note the key differences: there is no longer a good leaving group on sulfur (the alcoholate which would be a leaving group again is the conjugate base of a very weak acid), but if ethanol now attacks the carbon adjacent to what is now a tosylate group we have the tosylate anion as a good leaving group. In a second bimolecular nucleophilic substitution, tosylate and a proton are displaced and the ether is formed.



Notes:

[1]: Actually, which group is nucleophilic and which is electrophilic depends on the frontier orbitals, and that can also be used to unify both reaction types into one general scheme, but that analysis is very hard to do a priori.

[2]: Organic chemistry’s preference to write sulfonic sulfur atoms as doubly bonded to two oxygens, creating a dodectet gained popularity probably because of one of Pauling’s not-so-bright moments. However, evidence points towards d-orbitals (which would be required for the dodectet) not taking part in bonding for non-metals and thus the charge separation depiction being a more accurate description of the truth. This is documented a lot across this site.

[3]: Again, I won’t go into detail here when leaving groups are good or bad, but just leave as one principal pointer that conjugate bases of strong acids are bad leaving groups. The conjugate base of $\ce{OH-}$ is $\ce{H2O}$ which is a very weak acid; thus, hydroxide is a very bad leaving group.

[4]: Technically, this is no longer an $\mathrm{S_N2}$ reaction. Since sulfur is participating as the central, electrophilic atom, the transition state is more long-lived involving a four-electron three-centre bond. The difference is marked enough to call this bimolecular nucleophilic heavy atom substitution or something along the lines. It will usually not be referred to as an $\mathrm{S_N2}$ reaction.