Short answer: we may never know how -く arose. -かった (e.g. 楽しかった) can be synchronically analyzed as the contraction of -く and あった (i.e. 楽しく + あった).
The origin of -く is indeed tricky, since as naruto mentioned in the comment it is attested from antiquity.
According to Frellesvig, B. (2010). A history of the Japanese language. Cambridge: Cambridge University Press.
we interpret these formants as forms of a restricted copula ('adjectival copula') and gloss examples accordingly, e.g. samu-ku cold-ACOP.INF 'coldly'. This interpretation of the formants attaching to the adjective stem finds further support in its relations to some other grammatical forms
and considers the resemblance of the adjectival copula to the past tense auxiliaries ("ki ... used in old japanese to indicate past or so") in your question.
As for -katta, it is more straightforward.
In OJ (=Old Japanese) the existential verb ar- was used with the infinitive of the adjectival copula (-ku)
, the regular copula (ni, to) and the negative auxiliary (-zu) to form analytic forms, and these combinations sometimes fused phonologically: ADJ-ku ar- => ADJ-kar-, NOUN-ni ar- => NOUN-nar-, NOUN-to ar- => NOUN-tar-, VERB-zu ar- => VERB-zar-. In EMJ (=Early Middle Japanese) the fused forms gave rise to secondary conjugations
It may not be historically (i.e. diachronically) accurate to say that 楽しく and あった contracted to form 楽しかった, since the form あった is attested much later than the phonologically fused form たのしかr-. However, just like it is perfectly acceptable to say that the word "ability" is from "able" + "-ty" (rather than tracing it all back to Latin words habilis and habilitās), the synchronic analysis of 楽しかった as 楽しく + あった is a perfectly valid one.
For completeness, other analyses of forms historically related to the existential verb ある include:
- 楽しかろう, synchronically 楽しく + あろう
- 堂々たる, synchronically (and diachronically) 堂々と + ある
- 許されざる, which is 許されず + ある
- 華麗なる, which is 華麗に + ある
- 良かれ悪【あ】しかれ, which is 良く + あれ + 悪【あ】しく + あれ
Most of these forms are now quite dated though.