What is the origin of the word and how did it come to mean "complete and ready to be used immediately"?
1650s, "jailer," from turn (v.) + key (n.). In reference to a job that only has to be done only once, it is recorded from 1934. The notion probably is of something that can be accomplished with a single turn of a key.
Its usage as 'complete and ready to use' is relatively recent.
The term turnkey is also often used in the technology industry, most commonly to describe pre-built computer "packages" in which everything needed to perform a certain type of task (e.g. audio editing) is put together by the supplier and sold as a bundle. This often includes a computer with pre-installed software, various types of hardware, and accessories. Such packages are commonly called appliances. A website with a ready-made solutions and some configurations is called a turnkey website.
Turnkey products are synonymous to "off-the-shelf" solutions and not customized.
in the early 1900's Turn key was used to in places where the new Edison light bulb was being used, in place of lanterns. Notices were put up that read "This room is equipped with Edison Electric Light. Do not attempt to light with match. Simply turn key on wall by door." It stands to reason that it was a simply approach to a complicated thing.