Hi Franziska,
Welcome to the forum. I believe that your plot has no legend because it does not need it. You only need a legend if you are trying to distinguish between two or more things on the plot.
library(tidyverse)
dat2 <- tibble(aa = 1:20, bb = 20:1)
dat2 <- tibble(aa = 1:20, bb = 20:1, zz =rep(c("A", "B"), each = 10))
# no legend
ggplot(dat1, aes(aa, bb)) + geom_line(colour="darkgreen")
#legend because I am looking at the line by the zz variable.
ggplot(dat2, aes(aa, bb)) + geom_line(aes(colour = zz))