edited for pointless banter
This is according to
Chabad, but only regarding the melachot.
And this one is from
some other site, about why they'd relate.
If you don't feel like going through all of it, here are very short versions:
Chabad site:
Our sages explain: the fortieth labor is the "work of heaven" we do on Shabbat.
Building the Mishkan actually involves forty categories of creative work: the thirty-nine modes of constructive involvement with the physical world in which we engage during six days a week and which we cease on Shabbat; and the spiritual labor of Shabbat. The fortieth labor requires the cessation of the first thirty-nine, for this is the act of stepping out of, and above, our weekday Mishkan building; yet it is ultimately an indispensable component of the job of constructing a home for G-d in our physical lives.
Other site:
According to Rav Daniel, the Maharal of Prague tells us that the number 40 alludes to the very havayah (totality) of the Sabbath, and the very havayah of a person. The totality of the Sabbath, in the halachic sense, consists of 39 negative commandments (i.e. please don't do these creative activities) and one positive commandment (i.e. please REST YOURSELF), which equal 40. When someone commits a sin punishable by lashes, they might actually DESERVE 40 lashes according to the law… but, according to the Maharal, we only give that person 39 lashes because we don't want to nullify his very existence. 40 lashes would spiritually, if not physically, annihilate him completely.