How did we arrive to 40 hr work week? I am interested in a (reasonably) quantified explanation of why the work week in most of the world is 40 hrs and not for example 20? How did we arrive to the number 40.

Another question is, and here I understand I can't expect quantification so much, is why there are more part time jobs available in the low income range (menial work) but not so much among knowledge workers? For example, I am a software engineer living in a major metropolitan area, still finding part-time work is very hard. Seems like everyone wants full-time employees or at least contractors.

I am perplexed by this state of the labor market and would like to learn some perspectives on this from schooled economists.
The 40-week comes started with the movement of the 8h working day. The wikipedia article makes a quick summary of the historical progress of thinking from 12h work days in Britain during the industrial revolution to the nowadays 8h/day.
The quick summary is that after the first world war, the International Labour Organization (ILO) was formed and its first convention was defining limits for the work day:

Having decided (...) the &quot;application of the principle of the 8-hours day or of the 48-hours week&quot; which is the first item in the agenda

From Convention Limiting the Hours of Work in Industrial Undertakings to Eight in the Day and Forty-eight in the Week (ILO, 1919)
This meant that generally workers would work 8h/day as a maximum, with 1 day of rest per week. 52 countries have ratified this convention, although not immediately.
The change for the 40h week came in 1935, with another ILO convention, which explains the motivations in its preamble:

Considering that unemployment has become so widespread and long continued that there are at the present time many millions of workers throughout the world suffering hardship and privation for which they are not themselves responsible and from which they are justly entitled to be relieved;
Considering that it is desirable that workers should as far as practicable be enabled to share in the benefits of the rapid technical progress which is a characteristic of modern industry; and
Considering that in pursuance of the Resolutions adopted by the Eighteenth and Nineteenth Sessions of the International Labour Conference it is necessary that a continuous effort should be made to reduce hours of work in all forms of employment to such extent as is possible;
adopts (...) the following Convention, which may be cited as the Forty-Hour Week Convention, 1935:

From: ILO Forty-Hour Week Convention, 1935 (No. 47)
This later convention has been ratified by 15 countries only.
Further recommendations on the reduction of hours were made in 1962 (source ILO). The ILO also has a page summarizing the work done in the last 100 years on working time, which is a great resource to learn more.