Can someone explain this?
Can someone explain why is there 在 in 我跟朋友在周末见面的时候，会喝啤酒。? I've seen another Duolingo sentence that doesn't use 在 like 你周末一般喜欢做什么.
There's a short answer and a long answer. The short answer first is that prepositions like 在 are often optional. Sometimes you need them. Sometimes you can leave them out. This is often linked to cadence, so if you just get an ear for the rhythm of Chinese speech, you can usually figure it out and do it intuitively.
The long answer explains what the inclusion of the preposition intends to achieve, and how that is related to the greater syntactic philosophy underlying Chinese sentence construction. （Which I find really interesting, so here we go...)
In Chinese prepositions are often left implied. Unless there is ambiguity in context, or you are writing in certain specific formal styles, they can often be omitted. They are necessary, however, when certain types of ambiguity creep into a sentence, and your two examples illustrate that quite well.
The first sentence is significantly more complex than the second. The main difference is that you only have one verb phrase in the second sentence, 喜欢做 while in the first sentence, you have two: 见面 and 会喝. This means that although you are discussing two different nouns before the verb (yourself, and the weekend) it's clear that the one verb applies to both. But when you have two verbs, it becomes ambiguous where your emphasis lies.
Let's think of the simplest version of the sentence possible (which is still not wrong, but has greater ambiguity) 我跟朋友周某见面喝啤酒. This sentence is understandable, and doesn't break any major rules, but it also has some pitfalls. These become much more apparent in English: Me with Friends, Weekend, See, Drink - Beer. That's cool as poetry, and being poetic will actually get you a long way in Chinese, but the emphasis of the sentence becomes confusing. Is the focus my relationship to my friends on the weekend? Or is it the relationship my friends and I have to the weekend? And how generally am I talking about this?
There would be two possible implications of this sentence: "My Friends and I drink beer when we meet, on the weekend" or "On the weekend I drink beer, when I see my friends." They mean the same thing. They won't really raise any confusion. This is why it's okay to omit many prepositions in China. But if you, as a speaker, want to clarify and emphasize which elements you are talking about, you can do so by adding a construction that clarifies which is the focus of the sentence.
To do this, you add "在... (n. + ) v. ...的时候.” This construction uses 在 and 的时候 to construct something like a clause (very different from the way clauses are constructed in English). It functions to say "At the time of (n. doing ) v. ...“ This is where things get historically interesting.
Why bother? In English we have commas to designate clauses, and so does Chinese. In fact, the punctuation makes the original sentence fairly unambiguous. But punctuation was only introduced to Chinese in the 20th century, and before that, it was mainly phrases like this that organized sentences in place of punctuation. (This is also why you see question words used to designate questions rather than simple question marks.)
And the story of how western style puncutation ended up in Chinese is also really interesting, because that's where history and language collide.
It all started during the Boxer Rebellion in 1901. Chinese rebels attacked the Qing Dynasty, in large part angered by their capitulation with foreign powers over the course of the 19th Century. They wanted to expel or kill the foreigners in China, and this provoked many western countries to get involved.
In the aftermath of the Rebellion, many countries demanded reparations from China, the idea had originally been that these reparations would be used to modernize China in partnership with the western nations, though in practice most countries just used this to take money and expand their colonial holdings. The US, however, followed the spirit of the treaty, and built hospitals and schools in Beijing, and then used part of its reparations fund to establish scholarships for Chinese students to study abroad in the US.
Among the first of those students was Hu Shi, who studied first at Cornell, then Columbia University, completing graduate work under American pragmatic philosopher John Dewey. He returned to China and instantly became a major, controversial intellectual figure. By 1918, the Qing Dynasty had fallen, and the country was in turmoil. During WWI Japan had seized German colonies in Shandong, and expanded its imperial reach into the heart of China. Frustrated with the concessions given to the Japanese in the Treaty of Versailles (especially since China wasn't even a belligerent in the war) many nationalist Chinese youth marched in protest against the Japanese Embassy in Beijing on May 4th, but it quickly transformed into a critique of the Chinese government, and traditional society. The May 4th Movement, and the greater New Culture Movement was lead by intellectuals like Hu Shi, with international experience, who wanted to modernize China.
Until 1918, books were mainly published in Classical Chinese, making them unreadable to the common people. The New Culture movement, led by thinkers like Hu Shi, sought to create a modern, common, vernacular language to replace Classical Chinese in official documents. This was not just modernization, though, but a plan to democratize access to information and discourse in China.
In 1918, the students of the New Culture Movement opened up their own press (which still exists in Beijing today) and began printing books in new, vernacular forms of Chinese. One of them was Hu Shi's 中國哲學史大綱 (An outline of the history of Chinese philosophy). This was the first book published to use western style punctuation marks, and it became a touchstone for new syntactic innovations that continue to transform the Chinese language to this day.